I’m using a IPython notebook to write a program using pygame library. Here, I want to import an image file to the programme. Following is the code piece I would have used.
car = pygame.image.load('car.jpg')
But to do this, the image has to be in the same directory as the python file. Where are these IPython notebook files saved? Or is there any other way I can import this file to program in IPython notebook?
I’m using windows 7.
There are an number of ways to change directories or specify full paths:
cdcommand to change directories (if ‘automagic’ is enabled; use%cdif not), orspecify a path:
or
or
Although
cdis convenient while working in IPython, for your program you are better off specifying a full path tocar.jpg.