ipython problem in opening a file

Y

youngung

Hello pythoners!

I just dived into ipython since I'd like to make use of matplotlib.
Over the trials, I came across a problem.
One of the scripts that I have is not working with ipython, while it
has been and still is working well with Python GUI.

The problem is, even though I have the file in the c:\python26 folder,
IPython can't fine it.

One of the many things I tried, is as below.

*************************************************


f=open('od.txt','w')
---------------------------------------------------------------------------
IOError Traceback (most recent call
last)

C:\Windows\system32\<ipython console> in <module>()

IOError: [Errno 13] Permission denied: 'od.txt'



What should I do further to solve this problem?
 
E

Eli Bendersky

One of the many things I tried, is as below.
*************************************************


f=open('od.txt','w')
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call
last)

C:\Windows\system32\<ipython console> in <module>()

IOError: [Errno 13] Permission denied: 'od.txt'

It appears that your ipython runs in C:\Windows\system32
You can find it out for sure by executing "os.getcwd()" after
importing the "os" module.

You may not have permissions in C:\Windows\system32, which is why the
error is printed.

Eli
 
E

Eli Bendersky

Thank you for your kindness.
I found you're right. It's running in that folder.
What should I do for making this work?
Could you please tell me a bit more...

Youngung

You can change the "current directory" ipython executes in, by either
executing it directly (from the command line) in the directory of your
choice, or calling the os.chdir function with the path of your choice.

Eli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top