Search code examples
pythontweepy

Unable to import tweepy module


I am new to installing new python modules.

I installed tweepy using pip install tweepy. The installation was successful and 2 folders tweepy & tweepy-3.3.0.dist-info are created in the Lib/site-packages, hence I assumed all should be fine.

However, when I went to the IDE and import tweepy. It is unable to detect the module:

>>> import tweepy
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named tweepy

What is wrong?

I am running python 2.7.5.

[Update 1] I am using windows 7.

I first installed pip using another forum's suggestion (How do I install pip on Windows?). basically saving the get-pip.py script and double clicking it (unable to get "python get-pip.py" to work in cmd prompt as suggested). Then, I went to cmd and nagivated to C:/Python27/Scripts and type in pip install tweepy. I remembered seeing the result as a successful installation.

[Update 2] Using a file with import tweepy and running it, I have a similar error.

Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Users\xxxx\Desktop\Script1.py", line 2, in <module>
    from tweepy import Stream
ImportError: No module named tweepy

[Update 3] Typed "pip freeze" in cmd. It does show tweepy=3.3.0

C:\Python27\Scripts>pip freeze 
oauthlib==0.7.2 
requests==2.7.0 
requests-oauthlib==0.5.0 
six==1.9.0 
tweepy==3.3.0 
wheel==0.24.0

[Answer] Thanks for all the help guys, especially Cleb & omri_saadon suggestion that there might be something wrong with the file path.

I just realised that my GIS software, ArcGIS by default installed another Python into the Python27 folder, and everything is taken from that folder, C:\Python27\ArcGIS10.2, instead of C:\Python27. After I install tweepy from C:\Python27\ArcGIS10.2\Scripts, everything works well.


Solution

  • Try to pip uninstall tweepy

    and then again pip install tweepy

    Make sure you don't have several interpreters on your computer, if you have several, make sure that your pycharm(or any other editor you use) is configured with the same interpreter where you installed tweepy.