3

I installed pip in a virtual environment. It installed without errors. Here's what I get when I run sudo pip install tweepy after activating the venv:

Requirement already satisfied (use --upgrade to upgrade): tweepy in  
/usr/local/lib/python2.7/dist-packages/tweepy-3.1.0-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): requests==2.4.3 in
/usr/local/lib/python2.7/dist-packages/requests-2.4.3-py2.7.egg (from tweepy)
Requirement already satisfied (use --upgrade to upgrade): requests-oauthlib==0.4.1 in 
/usr/local/lib/python2.7/dist-packages/requests_oauthlib-0.4.1-py2.7.egg (from tweepy)
Requirement already satisfied (use --upgrade to upgrade): six==1.7.3 in 
/usr/local/lib/python2.7/dist-packages/six-1.7.3-py2.7.egg (from tweepy)
Requirement already satisfied (use --upgrade to upgrade): oauthlib>=0.6.2 in 
/usr/local/lib/python2.7/dist-packages (from requests-oauthlib==0.4.1->tweepy)
Cleaning up...

So, I'm sure it worked.

When I run a sample tweepy script I get this error:

./twitterStream.py
Traceback (most recent call last):
  File "./twitterStream.py", line 6, in <module>
    import tweepy
ImportError: No module named tweepy

My script wasn't specifying any python interpreter. To make sure it wasn't looking else where I now specify the interpreter in the venv.

Any ideas?

Thanks!

more info:

if i use 'pip install tweepy' i get a whole bunch of errors:

(venv)user@ubuntu:~/code/twitterStream$ pip install tweepy
Traceback (most recent call last):
  File "/home/user/code/twitterStream/venv/bin/pip", line 9, in <module>
    load_entry_point('pip==1.1', 'console_scripts', 'pip')() 
  File "/home/user/code/twitterStream/venv/local/lib/python2.7/site-  
packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
  File "/home/mukul/code/twitterStream/venv/local/lib/python2.7/site- 
packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 2279, in load_entry_point
    return ep.load()
  File "/home/user/code/twitterStream/venv/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 1989, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/home/user/code/twitterStream/venv/local/lib/python2.7/site-packages/pip-1.1-  
py2.7.egg/pip/__init__.py", line 10, in <module>
    from pip.backwardcompat import walk_packages, console_to_str
  File "/home/user/code/twitterStream/venv/local/lib/python2.7/site-packages/pip-1.1-
py2.7.egg/pip/backwardcompat.py", line 77, in <module>
from urllib2 import URLError, HTTPError
  File "/usr/lib/python2.7/urllib2.py", line 94, in <module>
    import httplib
  File "/usr/lib/python2.7/httplib.py", line 79, in <module>
    import mimetools
  File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
    import tempfile
  File "/usr/lib/python2.7/tempfile.py", line 32, in <module>
    import io as _io
  File "/usr/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: No module named _io

Edit: solved the errors thanks to: ImportError: No module named _io in ubuntu 14.04

Community
  • 1
  • 1
wholly_cow
  • 795
  • 3
  • 11
  • 19
  • Did you set `source`? Also: http://stackoverflow.com/questions/1871549/python-determine-if-running-inside-virtualenv And can you include how you set `virtualenv`? – jmunsch Dec 12 '14 at 20:21
  • I did do source bin/activate to activate the env - is that what you meant? I'll do the sys.real_prefix check once my system finished an upgrade . – wholly_cow Dec 12 '14 at 20:30

3 Answers3

2

Don't use sudo to call pip when you're in a virtualenv: the root user won't have the virtualenv activated so the package is installed globally, as you can see from the paths. Just run pip install tweepy.

Daniel Roseman
  • 541,889
  • 55
  • 754
  • 786
-1

Since you are using virtualenv you don't need to use sudo.

Patryk
  • 18,244
  • 37
  • 110
  • 212
-1

For installing the tweepy module just write pip install tweepy and it will work

  • 2
    He said that he tried that and it didn't work. Should we assume that if he tries again, it will? – zondo Feb 16 '16 at 01:25