[Tutor] Installing Modules
Downey, Patrick
PDowney at urban.org
Wed Jan 18 19:07:16 CET 2012
Hello,
I'll start by saying that I have a math/stats background, not a computer
science one. I've found lots of great material to help with Python
programming, but have had a much harder time getting my head around setup
issues, like installing modules.
I'm currently running Python version 2.7 through IDLE on a Windows machine.
I'm trying to use numpy and scipy. I downloaded both modules from the scipy
website and unzipped the files into:
C:\Python27\Lib\site-packages
I try to load them using this at the beginning of my program.
from numpy import *
from scipy import *
And I get this error:
Traceback (most recent call last):
File "D:/Documents and Settings/pdowney/My Documents/Actual
Projects/Foreclosures/Python/Program (1-18-12).py", line 3, in <module>
from scipy import *
ImportError: No module named scipy
Numpy loads just fine. Both are in the same folder. That is, there's a file
called setup.py in the folder:
C:\Python27\Lib\site-packages\numpy
And also in the folder:
C:\Python27\Lib\site-packages\scipy
I don't understand what is being done differently between the two packages.
According to Chapter 6 of the Python documentation, "When a module named
spam is imported, the interpreter searches for a file named spam.py in the
directory containing the input script and then in the list of directories
specified by the environment variable PYTHONPATH." Unfortunately, I haven't
figured out how to look at PYTHONPATH, so I don't know where it's looking.
>>> print PYTHONPATH
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
print PYTHONPATH
NameError: name 'PYTHONPATH' is not defined
Importantly, there is no file scipy.py in the scipy folder, as the
documentation suggests there should be, but there's also no numpy.py in the
numpy folder and that module loads successfully. Clearly I'm missing
something in the setup of these modules. Any guidance would be greatly
appreciated.
Thank you,
Mitch
More information about the Tutor
mailing list