# "module could not be found" error

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Mar 20 03:07:51 CET 2013

On Tue, 19 Mar 2013 15:58:51 +0000, Robert Flintham wrote:

> Joel: The 2.7 is the version number of the PyDev plugin for Eclipse,
> rather than the Python version number.
>
> Dave: I don't have access to the system's PATH environment variable
> because this computer is very tightly controlled.  However, my user PATH
> environment contains "K:\Python33", which I haven't had a problem with
> before when importing modules from site-packages.

You seem to have a conflict between Eclipse, which is expecting Python
2.7, and your PATH, which is Python 3.3. It's possible that you've got
some Python 3.3 modules in a Python 2.7 installation, and things are
getting confused.

By the way, do you mean the PYTHONPATH, which is different from the PATH?
I don't use Windows, so I might be missing something, but normally Python
will search for modules in the PYTHONPATH, not PATH. The best thing to do
is to check what path Python is using at run-time rather than to try to
predict from the PATH or PYTHONPATH environment variables. Put this at
the very beginning of your code, and report what it prints.

import sys
print (sys.version)
print (sys.path)

(I've included parentheses around the print calls in case you're running
under Python 3.)

Another thing to try, can you run your code directly without using
Eclipse? It may be that Eclipse is confused and if you run the code
directly it will be fine. From your Windows command line (cmd.exe, I
think) try running this command and see what it does:

python C:\path\to\my\project\myproject.py

You may need to provide the full path to the python executable.

--
Steven