[wingide-users] Python path & path problems

SirJSR sirjsr at gmail.com
Mon Jan 29 15:12:33 MST 2007


At the Wing console I issued the following, as instructed:

  import os
  print os.getcwd()

It showed that I was in the correct directory, inddicating no problem.

Then I issued the following:

  import sys
  sys.path.append('path/to/my script directory/')

And that seemed to work---I could then run the script with the "import"
command.

However, according to the first instruction, I was in the correct directory
already.  Any answer to this inconsistency.

And does the second command "stick"?  What does it append my new path to?

I am making progress, so that's good.

Thanks, Jim


-----Original Message-----
From: Michael Foord [mailto:fuzzyman at gmail.com] On Behalf Of Michael Foord
Sent: Monday, January 29, 2007 2:43 PM
To: SirJSR
Subject: Re: [wingide-users] Python path & path problems

SirJSR wrote:
> I am just beginning to use the Wing IDE Personal, and I am new to python.

The directory your module is in needs to be on the path.

Try doing the following at the Wing console.

import os
print os.getcwd()

This will print the current directory to the console. I think you will find
it isn't the directory where your script is.

Then do:

import sys
sys.path.append('path/to/my script directory/')

then try importing your module.

Fuzzyman
http://www.voidspace.org.uk/python/articles.shtml
>  
> I am trying to use the "import" command at the interactive prompt.  I 
> have simple scripts that work in the IDE, but when I go to the 
> interactive shell and enter "import filename" I get a response that 
> the file cannot be found:
>  
>     Traceback (most recent call last):
>   File "<string>", line 1, in <string>
> ImportError: No module named chaos
>  
> I have read as much as I can about paths, Pythonpath, etc., but I 
> can't get it to work.  I also have Cygwin, and if use that shell, and 
> by changing the directory to to where my scripts are located, I can 
> use the "import" command successfully.
>  
> I have tried adding to my Windows XP Path variable the following:
>  
>     
> C:\Python25;C:\Python25\DLLs;C:\Python25\Lib;C:\Python25\Lib\lib-tk;C:
> \Python25\Lib\compiler;
>  
>     and the following directory listings to where I keep the scripts 
> (they are actually in the last entry):
>  
>     C:\cygwin\bin;C:\cygwin\home\ "me-the 
> user)";C:\cygwin\home\"me-user"\bin;C:\cygwin\home\"me-user)"\python;
>  
> I also created a "Pythonpath" variable:
>  
>     
> C:\Python25;C:\Python25\DLLs;C:\Python25\Lib;C:\Python25\Lib\lib-tk;C:
> \Python25\Lib\compiler
>  
> None of this seems to do the trick.  As you can see, I've added 
> everything under the sun.  Do I need all these entries?
>  
> I've Googled for the proper solution, and I haven't been able to get it.
>  
> For informational purposes, how does the "Pythonpath" differ from the 
> system path.  Is it just a subset, does it replace that part of they 
> system Path, etc?  Why is it necessary?
>  
> Any help would be appreciated.
>  
> Jim Roberts
> ----------------------------------------------------------------------
> --
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide



More information about the wingide-users mailing list