1

I have written a module to be used in the DataNitro iPython shell, but I think the problem is more general than just to the DataNitro shell:

I can successfully import the module when I do the following in the DataNitro iPython shell:

import sys
sys.path.append(path/to/WorkbookFunctions.py)
import WorkbookFunctions as wf

But when I close the shell and open again and do the following:

import sys
sys.path

the path I added previously is not there.

How do I make the path permanent in the sys.path directory?

Thanks

Woody Pride
  • 13,539
  • 9
  • 48
  • 62

2 Answers2

2

If you want to have a module generally importable when you use Python, you should add it to a folder on the Python path, rather than modify the path. (Typically, you'll use Python27/lib/site-packages on Windows.)

However, if you're just working with a local file, the best thing to do is to keep it in your working folder: Python will always check the local directory before moving further down the path. In the case of DataNitro, this will be the directory your workbook is in.

Ben Lerner
  • 1,318
  • 9
  • 12
0

Alternatively, if you do want to modify your path, you can follow this answer and use .pth files. I, personally, find this very useful.

Community
  • 1
  • 1
TomCho
  • 3,204
  • 6
  • 32
  • 83