Member Avatar for bdesc100

I am trying to add a path to sys.path fix an error importing numpy. If I do:

import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages')
print sys.path

then path that I just added shows up and import numpy works. However, if I restart IDLE and try to import numpy again, I get an error. How can I make the path stay permanently?

Snow Leopard, Python 2.6

You need to add these 2 lines to the beginning of your program code ...

import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages')
Member Avatar for bdesc100

You need to add these 2 lines to the beginning of your program code ...

import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages')

I know that that would work; I am asking if there is a way to permanently add the path to sys.path so that I don't have to run that code every time... For instance, the other paths that show up when I run sys.path are permanently stored there...

Sorry, I don't use Unix, maybe something like this Linux advice will help, see:
http://www.daniweb.com/forums/post1028888.html#post1028888

Here is another approach:

If you want to import custom module xyq via the Pythonpath,
create a file xyq.pth and stick it into a directory python
will look into, like
C:/Python25/Lib/site-packages (for Windows)
/usr/lib/python2.5/site-packages (for Linux)

The .pth file contains a line showing the directory
in which module xyq is located, for instance:
C:/Python25/MyModules (for Windows)
/usr/lib/python2.5/mymodules (for Linux)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.