Skip to content Skip to sidebar Skip to footer

Python Importerror When Module Is In Sys.path

I'm working with Python in the command line and want to import the module 'twitter'. twitter is in this directory: C:\Users\U908153\AppData\Local\Enthought\Canopy32\User\Lib\site-p

Solution 1:

A few things that commonly result in this error:

  1. Module is not in PYTHONPATH. Since you have checked this with sys.path, I will assume that it is there already. However, for future reference, you can manually add it to your profile or bashrc file in the home directory.

  2. It may be that the module that you are using doesn't have a __init__.py file or the module path in PYTHONPATH doesn't point to the uppermost directory with __init__.py. You can fix this by adding a blank __init__.py file where necessary or editing the module path.

  3. Another possibility is that the python interpreter that you used sys.path is not the same python in which the module was installed. Commonly, this is due to two different versions of python installed on the same machine. Make sure that your module is installed for the correct python interpreter or switch into the correct (usually not default) python using source activate.

Hope this helps!

Post a Comment for "Python Importerror When Module Is In Sys.path"