19

I've tried to install a python module:

virtualenv . source bin/activate pip install utmp 

It seems to be installed:

(wtmp)chris@chris-nb:~/computer/wtmp$ find -iname utmp ./bin/utmp ./lib/python2.7/site-packages/utmp 

But Python says it wasn't found:

(wtmp)chris@chris-nb:~/computer/wtmp$ ./wtmp.py Traceback (most recent call last): File "./wtmp.py", line 3, in <module> import utmp ImportError: No module named utmp 

Is this a module issue? Did I do something wrong?

If it matters, the OS is Ubuntu.

Here's the re-install log:

(wtmp)chris@chris-nb:~/computer/wtmp$ pip install --upgrade --no-deps --force-reinstall utmp Downloading/unpacking utmp Downloading utmp-0.4.tar.gz Running setup.py (path:/home/chris/computer/wtmp/build/utmp/setup.py) egg_info for package utmp zip_safe flag not set; analyzing archive contents... flake8.reporter: module references __file__ flake8.tests._test_warnings: module references __file__ flake8.tests.test_integration: module references __file__ Installed /home/chris/computer/wtmp/build/utmp/flake8-2.4.1-py2.7.egg Searching for six Reading https://pypi.python.org/simple/six/ Best match: six 1.9.0 Downloading https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz#md5=476881ef4012262dfc8adc645ee786c4 Processing six-1.9.0.tar.gz Writing /tmp/easy_install-oJJB7w/six-1.9.0/setup.cfg Running six-1.9.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oJJB7w/six-1.9.0/egg-dist-tmp-1116oK no previously-included directories found matching 'documentation/_build' zip_safe flag not set; analyzing archive contents... six: module references __path__ Installed /home/chris/computer/wtmp/build/utmp/six-1.9.0-py2.7.egg Searching for mccabe>=0.2.1,<0.4 Reading https://pypi.python.org/simple/mccabe/ Best match: mccabe 0.3.1 Downloading https://pypi.python.org/packages/source/m/mccabe/mccabe-0.3.1.tar.gz#md5=9a1570c470ff5db678cc0c03d5c0c237 Processing mccabe-0.3.1.tar.gz Writing /tmp/easy_install-uFdTms/mccabe-0.3.1/setup.cfg Running mccabe-0.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-uFdTms/mccabe-0.3.1/egg-dist-tmp-Q139di Installed /home/chris/computer/wtmp/build/utmp/mccabe-0.3.1-py2.7.egg Searching for pep8>=1.5.7,!=1.6.0,!=1.6.1,!=1.6.2 Reading https://pypi.python.org/simple/pep8/ Best match: pep8 1.5.7 Downloading https://pypi.python.org/packages/source/p/pep8/pep8-1.5.7.tar.gz#md5=f6adbdd69365ecca20513c709f9b7c93 Processing pep8-1.5.7.tar.gz Writing /tmp/easy_install-BdNCrK/pep8-1.5.7/setup.cfg Running pep8-1.5.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-BdNCrK/pep8-1.5.7/egg-dist-tmp-rrUWb1 warning: no previously-included files matching '*.pyc' found under directory 'docs' warning: no previously-included files matching '*.pyo' found under directory 'docs' warning: no previously-included files matching '*.pyc' found under directory 'testsuite' warning: no previously-included files matching '*.pyo' found under directory 'testsuite' no previously-included directories found matching 'docs/_build' Installed /home/chris/computer/wtmp/build/utmp/pep8-1.5.7-py2.7.egg Searching for pyflakes>=0.8.1,<0.9 Reading https://pypi.python.org/simple/pyflakes/ Best match: pyflakes 0.8.1 Downloading https://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.8.1.tar.gz#md5=905fe91ad14b912807e8fdc2ac2e2c23 Processing pyflakes-0.8.1.tar.gz Writing /tmp/easy_install-R5ltqy/pyflakes-0.8.1/setup.cfg Running pyflakes-0.8.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-R5ltqy/pyflakes-0.8.1/egg-dist-tmp-a8CCFW zip_safe flag not set; analyzing archive contents... pyflakes.checker: module references __file__ pyflakes.checker: module references __path__ pyflakes.test.test_api: module references __file__ pyflakes.test.test_undefined_names: module references __file__ pyflakes.test.test_undefined_names: module references __path__ Installed /home/chris/computer/wtmp/build/utmp/pyflakes-0.8.1-py2.7.egg warning: no files found matching '*.rst' under directory 'docs' warning: no files found matching '*.py' under directory 'docs' Installing collected packages: utmp Found existing installation: utmp 0.4 Uninstalling utmp: Successfully uninstalled utmp Running setup.py install for utmp warning: no files found matching '*.rst' under directory 'docs' warning: no files found matching '*.py' under directory 'docs' Installing utmp script to /home/chris/computer/wtmp/bin Successfully installed utmp Cleaning up... 

2 Answers 2

26

Just bumped into the same issue. I found out what is wrong by using which python. It showed me that I actually have an alias in place which points to a different python executable than the one in current virtualenv. Apparently aliases are more important than paths set via source.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes,aliases take precedence. Why is that related to the question?
It is related because this can be one of possible causes of why a Python module can not be found in virtualenv. If someone would have posted it here earlier, I would solve my problem faster, thus I thought I will add my solution as a hint here.
18

You can check whether it is installed in your virualenv by calling pip list or pip show utmp.

If not, try to reinstall it:

pip install --upgrade --no-deps --force-reinstall utmp

and extend your question with the error log.

Also verify the shebang line as it might point not to your virtualenv.

6 Comments

It seems to be installed: (wtmp)chris@chris-nb:~/computer/wtmp$ pip list argparse (1.2.1) enum (0.4.4) pip (1.5.4) setuptools (2.2) utmp (0.4) wsgiref (0.1.2)
Have you tried to reinstall it: pip install --upgrade --no-deps --force-reinstall utmp?
I've added the re-install log above.
Can you try to launch python interpreter and just type import utmp. If this works, problem lies in the wtmp.py script. Check the shebang line as it might point not to your venv.
Thank you! I used the wrong Shebang line! It's some time ago since I've used python and virtualenv the last time.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.