0

I've created some module, and would like to access it through another Python script in Enthought Canopy. When I attempt to do the same thing using python directly through the command line, this works just fine -- I just import myfile.py. Additionally, I know that my default Python distribution on this machine is Enthought Canopy. Anyone know why I'm not able to access the module I've created from within a Python script in the Canopy editor? It just says there is 'No module named myfile', even though myfile.py is in the same directory.

orange1
  • 2,871
  • 3
  • 32
  • 58
  • 1
    what is your current working directory? `import os os.getcwd()` – Padraic Cunningham Sep 10 '14 at 16:39
  • Oh, it's just /Users/MyUsername . That makes sense then, it doesn't know where to find the file. Is there a way to specify the file path that it should follow, or to set the working directory for Canopy? – orange1 Sep 10 '14 at 17:47
  • 1
    I think there is but from memory I cannot remember how, it is a long time since I use canopy, you could use `os.chdir(path)` to change the directory, I am not sure if you can maybe just `cd` to the directory. – Padraic Cunningham Sep 10 '14 at 17:51
  • this may be useful http://stackoverflow.com/questions/16848231/python-in-enthought-canopy-ioerror-no-such-file-or-directory/16848410#16848410 – Padraic Cunningham Sep 10 '14 at 18:01
  • Ahah! You can in fact just cd into the directory. Thanks! – orange1 Sep 11 '14 at 13:59

1 Answers1

0

There was an issue with the current working directory--it's not set by default to where the file is saved. cding into the directory with the module in it fixed it.

orange1
  • 2,871
  • 3
  • 32
  • 58