0

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

Edited by bdesc100: n/a

2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by vegaseat
0

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')
0

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...

0

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)

Edited by vegaseat: .pth files

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.