10

Working on a django project I cloned into and I'm trying to run an initial syncdb in my virtualenv. When I do, it throws

ImportError: No module named importlib 

What's really perplexing to me is this: I specifically ran

pip install importlib

Requirement already up-to-date: importlib in /Users/virtualenv/lib/python2.6/site-packages

ok, so it's probably not on my python path, so I've made sure it's been added:

$ >>> import sys
$ >>> sys.path.insert(0, "/Users/virtualenv/lib/python2.6/site-packages")
$ >>> sys.path.insert(0, "/Users/virtualenv/lib/python2.6/site-packages/importlib")

now, if I import importlib it's there

$ >>> print importlib
<module 'importlib' from '/Users/virtualenv/lib/python2.6/site-packages/importlib/__init__.pyc'>

but if I run $ python manage.py syncdb it continues to give me the ImportError. Any thoughts on further tests I can run or what might be causing this? thanks

Django version is 1.5.3, Python version within the virtualenv is 2.6.8

>>> print sys.version
2.6.8 (unknown, Apr 19 2012, 01:24:00)  
bignose
  • 30,281
  • 14
  • 77
  • 110
Chris B.
  • 1,505
  • 5
  • 26
  • 48
  • This might help: http://stackoverflow.com/questions/9072076/ – flornquake Sep 16 '13 at 01:02
  • 1
    are you sure you ran the pip from your virtualenv? What's the output of `which pip` – Jeff Tratner Sep 16 '13 at 02:10
  • yes pip was run within virtualenv. which pip output: /Users/virtualenv/bin/pip – Chris B. Sep 16 '13 at 02:31
  • 6
    Are you sure you're running the _python_ from the virtualenv? Because if you are, that `site-packages` directory ought to have already been on `sys.path`. Instead of guessing, try `print`ing it out. If it's not there, then either you're not running the virtualenv Python, or your virtualenv is horribly screwed up and you should create a new one. – abarnert Sep 16 '13 at 05:18
  • Meanwhile, `importlib` almost certainly shouldn't be on `sys.path`. You want to use it as a top-level package, not use its contents as separate top-level modules and packages And certainly not both at the same time. – abarnert Sep 16 '13 at 05:19
  • Probably a duplicate of https://stackoverflow.com/questions/44299495/from-django-utils-importlib-import-import-module-importerror-no-module-named-im, or very similar. Not really possible to know without a traceback. – snakecharmerb Jul 25 '20 at 15:21

1 Answers1

0

Try reinstalling importlib. You can remove the package with pip uninstall importlib. Then you can try installing it again.

Kevin Gray
  • 31
  • 5