1

I'm having trouble importing numpy into my script because of some path-name issues.

I'm running my script with python 2.7, rather than the default 2.6 on my server because I need some of the updates in the Collections module. I cant seem to import numpy like:

from numpy.random import poisson

So I am trying to use the python2.7 specific links to numpy on my server, which are installed in: /opt/lib/python2.7/numpy

But this period in the path is really making this difficult. I cannot change the path in anyway.

I've found a similar problem here, but frankly the code just doesn't make enough sense to me for me to feel safe using it (plus several commenters seemed to suggest it was a bad idea.). If someone has another suggestion, or if you can give me a good explanation of the code there I would appreciate it.

Community
  • 1
  • 1
FabbyRob
  • 31
  • 1
  • 3

1 Answers1

1

Try setting PYTHONPATH to point to /opt/lib/python2.7, after which import numpy et cetera should pull libraries from there.

$ PYTHONPATH=/opt/lib/python2.7 python27 my_script.py
Amber
  • 507,862
  • 82
  • 626
  • 550