1

I'm relatively new to coding but feel like I have a firm understanding of the basics. I am looking to use python to experiment with twitter using the tweepy module but I'm having trouble install it, and other modules too, using pip in the command line.

Typing pip pip install tweepy into the command line (Terminal on macOS Sierra) returns the string of errors at the end of this post.

If anyone could shed any light onto why I can't install any modules I would very much appreciate it.

Thanks in advance.

Collecting tweepy
  Using cached tweepy-3.5.0-py2.py3-none-any.whl
Collecting six>=1.7.3 (from tweepy)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting requests-oauthlib>=0.4.1 (from tweepy)
  Using cached requests_oauthlib-0.7.0-py2.py3-none-any.whl
Collecting requests>=2.4.3 (from tweepy)
  Using cached requests-2.11.1-py2.py3-none-any.whl
Collecting oauthlib>=0.6.2 (from requests-oauthlib>=0.4.1->tweepy)
  Using cached oauthlib-2.0.0.tar.gz
Installing collected packages: six, oauthlib, requests, requests-oauthlib, tweepy
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/3m/f0y775rj4nj_xc8t0vntyjk80000gn/T/pip-thDOd4-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
Dan Edwards
  • 11
  • 1
  • 2
  • 1
    seems like you're installing that package system-wide, not in a virtualenv. try using sudo in front of your pip comment: sudo pip install tweepy – matias elgart Nov 14 '16 at 13:44
  • I am encountering the exact same problem. Even on using sudo, same error is thrown along with the message `The directory '/Users/aditinarware/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.` – Aditi Narware Dec 12 '16 at 06:07

3 Answers3

2

As mentioned above, you need root access where pip stores the packages.

Python 3.x:

sudo pip3 install tweepy

Python 2.x:

sudo pip install tweepy

You may also use Git to clone the repository from Github and install it manually:

git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install

Alternatively you can use virtualenv

"What if you can't install packages into the global site-packages directory? For instance, on a shared host.

In all these cases, virtualenv can help you. It creates an environment that has its own installation directories, that doesn't share libraries with other virtualenv environments (and optionally doesn't access the globally installed libraries either)."

Basically it's allow you to create an isolated environment for each of your project and it's help on permission issue you have.

For more information: Installing Python on Mac OS X: virtualenv

frfahim
  • 515
  • 9
  • 21
0

Operation not permitted

You need to run:

sudo pip install tweepy
Strobe_
  • 495
  • 1
  • 13
  • 34
  • Thank you for your quick reply. I have tried running `sudo pip install tweepy` but the same errors occur, preceded by the message below. Please forgive my ignorance! `The directory '/Users/dedwards/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.` – Dan Edwards Nov 14 '16 at 14:44
  • @Strobe_ I am having exactly the same issue, kindly help. – Aditi Narware Dec 12 '16 at 06:04
  • @AditiNarware have a look at the first answer on this link http://stackoverflow.com/questions/27870003/pip-install-please-check-the-permissions-and-owner-of-that-directory – Strobe_ Dec 12 '16 at 11:35
  • @Strobe_ I tried that but got this error `OSError: [Errno 1] Operation not permitted: '/tmp/pip-q5jhKJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info' ` what to do? – Aditi Narware Dec 16 '16 at 10:17
0

You have problems with permissions. As suggested above, you can try to use sudo

Nick
  • 11
  • 2