pypa / pip

The Python package installer

Home Page:https://pip.pypa.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Six issue when installing package

securitybites opened this issue · comments

commented

When trying to install awscli I get the following error.

admins-MacBook-Pro-5:~ user$ pip install awscli
Collecting awscli
  Using cached awscli-1.8.9-py2.py3-none-any.whl
Collecting botocore==1.2.7 (from awscli)
  Using cached botocore-1.2.7-py2.py3-none-any.whl
Collecting rsa<=3.3.0,>=3.1.2 (from awscli)
  Using cached rsa-3.2-py2.py3-none-any.whl
Collecting colorama<=0.3.3,>=0.2.5 (from awscli)
Collecting docutils>=0.10 (from awscli)
Requirement already satisfied (use --upgrade to upgrade): jmespath<1.0.0,>=0.7.1 in /Library/Python/2.7/site-packages (from botocore==1.2.7->awscli)
Collecting python-dateutil<3.0.0,>=2.1 (from botocore==1.2.7->awscli)
  Using cached python_dateutil-2.4.2-py2.py3-none-any.whl
Collecting pyasn1>=0.1.3 (from rsa<=3.3.0,>=3.1.2->awscli)
  Using cached pyasn1-0.1.9-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore==1.2.7->awscli)
  Using cached six-1.9.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, docutils, botocore, pyasn1, rsa, colorama, awscli
  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/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 716, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 315, 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/6t/h404bjcd5tb_4q86tpv_251rv_0h0j/T/pip-sYsqDS-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

Other user have mentioned the issue and point to pip:

aws/aws-cli#1522

https://bitbucket.org/gutworth/six/issues/134/uninstall-error-operation-not-permitted

You're on El-Capitan right?

I have this issue when installing AWS-SDK, which depends on six.

On El-Capitan indeed.

This is because OS X El Capitan ships with six 1.4.1 installed already and when it attempts to uninstall it (because awscli depends on botocore, botocore depends on python-dateutil, and python-dateutil depends on six >= 1.5) it doesn't have permission to do so because System Integrity Protection doesn't allow even root to modify those directories.

Ideally, pip should just skip uninstalling those items since they aren't installed to site-packages they are installed to a special Apple directory. However, even if pip skips uninstalling those items and installs six into site-packages we'll hit another bug where Apple puts their pre-installed stuff earlier in the sys.path than site-packages. I've talked to Apple about this and I'm not sure if they're going to do anything about it or not.

This affects many other packages which rely on Six, pardon my obliviousness, but is there any way to tell pip to either 1. install an updated version to /Library's site-packages and be pointed to prefer that one (instead of saying 'requirement satisfied! and exiting) or 2. ignore the version found in /System on 10.11+?

pip install --ignore-installed six

$ sudo -H pip install --ignore-installed six
Collecting six
  Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six-1.4.1

Sure, but pip won't then prefer that upgraded version of Six when performing sudo installs:

sudo -H pip install mock
Requirement already satisfied (use --upgrade to upgrade): mock in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): funcsigs in /Library/Python/2.7/site-packages (from mock)
Requirement already satisfied (use --upgrade to upgrade): pbr>=0.11 in /Library/Python/2.7/site-packages (from mock)
Collecting six>=1.7 (from mock)
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
  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-7.1.2-py2.7.egg/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_install.py", line 716, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/utils/__init__.py", line 315, 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: '/tmp/pip-sy_6uC-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

...
Sorry about that, for some reason it's working after... running it a second time? Needed to --ignore-installed mock as well.

Ah, so this is less a pip issue to address (although it seems like --ignore-installed is going to get very popular) than the user changing their path appropriately. (You'll just get all the support requests. Thanks, Apple!)
As per http://peak.telecommunity.com/DevCenter/setuptools#development-mode you can set a .pth file system-wide to make sure that directory is consulted first. I'll compose a radar to Apple so they can remove their heads from their butts about this.

...Shouldn't there be some other, more permanent fix? easy_install has a .pth file, so there is some precedent here. I've documented what I think is the best near-term solution here: http://apple.stackexchange.com/a/210021/216

THANKS! The following allowed it to install correctly.

pip install awsebcli --upgrade --ignore-installed six

Running on OSX El Capitan

$ eb --version
EB CLI 3.5.4 (Python 2.7.1)

@arubdesu I'm hoping the more permanent fix will be to have Apple just fix this, which I am talking to them about.

Hello all!
I came across the same problem(thank goodness for this post!) while trying to install virtualenvwrapper. As all of you, and lastly @reganjohnson suggested --upgrade --ignore-installed six will work.
I did
sudo pip install virtualenvwrapper --upgrade --ignore-installed six

Running El Capitan as well

P.S: Please forgive me if I'm not posting this correctly I'm a complete noob to github :(

sudo pip install virtualenvwrapper --upgrade --ignore-installed six

Did work for me! thanks guys

You can disable System Integrity Protection completely via running csrutil disable in recovery mode. Do at your own risk etc. etc.

Anyone can respond to this issue however they want, (playing chicken with Apple over this is like waiting for an updated version of rsync, in my opinion...) but if you're coming to this thread now, just know that you can work around this issue by:

  1. installing with pip to your user folder *
  2. installing with pip and --ignoring-installed *
  3. using a virtualenv
  4. installing your own python, e.g. with homebrew
    And after all of those options? Sure, you can TEMPORARILY disable SIP during the time you pip upgrade something in the System folder, but then you're also messing with the version Apple expects to be present. You can even "at your own risk etc. etc." disable, reboot, then enable --without fs to permanently stop just the filesystem protections. But I don't think you should get used to employing SIP-related fixes for python package installs, if anything the SIP-disabling options will go away, not get more lenient, so dealing with this new situation sooner rather than later seems wise.
    * also then possibly requiring you to employ a .pth file to ensure python picks up on your desired lookup order, as previously mentioned about sys.path

Just a suggestion friend, no need to get alarmed.

I agree with @arubdesu
Messing with system has never been a good idea.
Just use any of the other possibilities. And it's easier.

And I agree with @dstufft that Apple should hard-code any of their python package dependencies to the System folder and allow the default path to check /Library before /System. (Not that I'm putting words in his mouth, just saying that's what I filed a radar for. http://www.openradar.me/radar?id=6192110889861120)

both of these result in six version 1.41:
pip install --ignore-installed six
pip install awsebcli --upgrade --ignore-installed six
El Capitan must go down with the ship...

@monte-hayward Try pip install --user awsebcli (might need a --upgrade flag too).

Hi folks, FYI:
Engineering has determined that your bug report (23234649) is a duplicate of another issue (20471644) and will be closed.

If you fill a bug report please mention Radar # 20471644

I found the easiest solution was to use homebrew to install a local version of python (thus pip). This avoids the complexities of El Capitan's protected install of python and instead installs python into /usr/local/bin. The various solutions for the "--ignore-installed six" did not work on my system.

Just do:

brew install python

The pip install command should work fine after that.

More information is available here:
http://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-el-capitan-max-os-x-upgrade

Thanks much for this:
$ sudo pip install awscli --upgrade --ignore-installed six

Thanks all,

End-use virtualenv to solve problems

Thanks for this!

I had similar problem installing AWS Elastic Beanstalk on my El Capitan v 10.11.1
sudo pip install --upgrade awsebcli
The link below solved my issue.
http://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-el-capitan-max-os-x-upgrade/210021#210021

Also exists for installing google-api-python-client on El Captain.

sudo pip install --upgrade google-api-python-client --ignore-installed six

works!

n00b question. What the hell is six?

commented

Using --ignore-installed six worked like a charm. Thanks @dstufft and everyone else

this is working for me as well. thanks so much!

sudo -H pip install facebookads --ignore-installed six

this works for me

brew install python

pip install awscli
commented

@williamli after brew install python, which version of python will be installed?python2 or python3? and if I want switch to the other version, how can I specify?

@jacktan1991 try using virtualenvs. Using brew, python refers to 2 and python3 refers to 3. I would suggest you learn how to use virtualenvs, these will let you play with stuff in an isolated manner, so installing one thing in your global python environment, won't later mess up others.

https://virtualenv.pypa.io/en/latest/

After brew install python, I have Python 2.7.11 as the active client.
I don’t really care about which version of python I have on as I don’t do any python developments so I didn’t look into virtualenvs.

On 18 Jan 2016, at 21:18, Jack notifications@github.com wrote:

@williamli https://github.com/williamli after brew install python, which version of python will be installed?


Reply to this email directly or view it on GitHub #3165 (comment).

commented

@Ivoz I took your suggestion, less pain in developing with pythonY(^_^)Y

what did I do wrong? El Capitan

$ sudo -H pip install --upgrade --ignore-installed six
Collecting six
  Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six-1.4.1
$ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> six.__version__
'1.4.1'
>>> quit()

Now I want to install google grpc

$ sudo python setup.py install
Traceback (most recent call last):
  File "setup.py", line 205, in <module>
    test_runner=TEST_RUNNER,
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
    _setup_distribution = dist = klass(attrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 239, in __init__
    self.fetch_build_eggs(attrs.pop('setup_requires'))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 263, in fetch_build_eggs
    parse_requirements(requires), installer=self.fetch_build_egg
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 580, in resolve
    raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (six 1.4.1 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python), Requirement.parse('six>=1.10'))

---- is six 1.4.1 the latest version?

@pjm4github OS X 10.11's python retains its own copy of six which is unremoveable, because of modifications Apple has done to their python distribution. 1.4.1 is not the latest, 1.10.0 is. It also comes early on their python's import path, so it will typically override later versions you install.

I would suggest using a different python for now. Python.org's, or installed via Homebrew, or Anaconda Python.

Also exists for installing scrapy on El Captain.

sudo pip install --upgrade scrapy --ignore-installed six

works!

@airingursb sudo pip install --upgrade scrapy --ignore-installed six
the version of six is still 1.4.1

scrapy need six 1.5, but El Captain need six 1.4. use virtualenv to solve problems.

https://pypi.python.org/pypi/virtualenv

@gavinliu Actually I'm trying to install virtualenvwrapper to work with virtualenv. And virtualenvwrapper needs the six package.

@dstufft thanks

@extremewaysback you might be able to use --user install path (just add that after pip install command, for global context). Note, the binaries should then be stored in ~/.local/bin, which will need to be on your $PATH.

@Ivoz Thank you very much! It works using pip install --user virtualenvwrapper.

@Ivoz is right: pip install aws-shell --user works fine.

I use this when installing virtualenvwrapper. I works fine.
$ sudo pip install virtualenvwrapper --ignore-installed six

Great, but only fixed my local machine.

I came across installation issues with a particular project called bcwallet (I already had the python pip package installed). And tried every suggestion, but nothing worked. After factory resetting my computer, everything was fine and was working properly.

I found that when upgrading to El Capitan, you will end with the xcode cli broken.

Try the following:

xcode-select --install
brew reinstall python
pip install awscli

Thanks @3manuek that has solved the problem for me!

thanks @arubdesu - this really helped me!

sudo pip install boto3 --ignore-installed six
solved my boto3 install errors.
thanks for the post

sudo pip install django-kronos --upgrade --ignore-installed six
Solved my django-kronos install errors.
Running on OSX El Capitan

Thanks for the post @reganjohnson

sudo pip install pytest-bdd --upgrade --ignore-installed six
Couldn't install pytest-bdd on my mac, this one helped me out

thanks!

I got this problem when trying to uninstall xattr, altgraph etc....

OSError: [Errno 1] Operation not permitted: '/tmp/pip-IlFCGY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy-0.13.0b1-py2.7.egg-info'

Does anybody has a suggestion? Thanks a lot and sorry for my english.

Use of /tmp is wrong on OS X. The correct approach is to use https://docs.python.org/2/library/tempfile.html in order to get a temporary file or directory and not to rely on the /tmp availability.

This applies to any platform, not only OS X.

I use to write Nodejs and I am new to Python. Can I just delete tmp directory

commented

sudo pip install wechat-sdk --upgrade --ignore-installed six
it works!
thanks 🙃

$ sudo pip install --ignore-installed six awscli

works for me thanks

I personally think, do not touch OS packaged python, just use python via homebrew since it uses /usr/local/bin (if you set this path ahead of other). Maintaining legacy stuffs is not a simple task which may lead to more troubles between each updates.

For more details, maybe you just need to refer to this simple guide

@arubdesu I thought I should note here that I have /Library before /System in my sys.path and it still I still got the OSError: [Errno 1] Operation not permitted: when trying to install numpy v1.11.1 because v1.8.x is installed in /System by Apple (this is on macOS 10.12 beta). But pip install --upgrade --ignore-installed numpy was the only thing that worked.

sudo pip install --upgrade scrapy --ignore-installed six
Helpful for me:)

Disabling system integrity protection is contraindicated. Please don't do it or at least don't encourage others to do so without explaining all the risks. Instead there are many safer options:

  • use the --user option
  • use a virtual environment
  • use a python installed from a package manager like home brew or macports
  • compile your own Python

This is solved now with macOS Sierra.

Hi,
I have upgraded to macOs Sierra and unable to install boto3.

I have created virutalenv with below versions:

$python --version
Python 2.7.10

$pip --version
pip 8.1.2

Installing boto3 gives me error as

$ sudo pip install boto3 --ignore-installed six

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 1] Operation not permitted: '/bin/rst2html.py'

Running without sudo gives this error

$ pip install boto3 --ignore-installed six

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/lib/python2.7/site-packages/concurrent/__init__.py'

ALso i tried deactivating virtualenv and getting error, any help ?

Worked with sudo:
sudo pip install --ignore-installed six
sudo pip install awsebcli --upgrade --ignore-installed six

For Installing/upgrading python-openstackclient on OS X EI Capitan:
sudo pip install --upgrade python-openstackclient --ignore-installed six

@Heedster Spot on!

pip install --upgrade --ignore-installed google-api-python-client

It works.

For me , after upgrading the six version to 1.10.0, the system is not using this version, but older version, so I overwrite the new six.py and six.pyc into the older six file
sudo copy /Library/Python/2.7/site-packages/six.py /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Why exactly is this happening though?

I have the same issue with Sierra, "sudo pip install aws-shell --upgrade --ignore-installed six" worked for me.

I faced this issue installing virtualenvwrapper on macos sierra. This worked, but at what cost?

sudo pip install virtualenvwrapper --upgrade --ignore-installed six

I needed virtualenvwrapper to create the virtualenv where I would be performing various pip things.

I have decided to install python 2.7.13 and do not use the default python
OS: sierra 10.12

@dstufft man you saved my day!!
$ pip install --ignore-installed six indeed was the solution followed by a $ pip install --upgrade google-api-python-client
cheers!

@propupul Thaaaaanks

sudo pip install virtualenvwrapper --upgrade --ignore-installed six

and works in El Capitan

Getting Error while doing sudo pip install pytest-bdd
OSError: [Errno 1] Operation not permitted: '/tmp/pip-mGjtsa-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

Sierra has the same problem. And the same solution.

thank you forsudo pip install -U nltk --ignore-installed six
I have fixed the errors

Just here to say that the problem with six is not fixed on Sierra as of v10.12.6.

The same with dateutil.
Sierra (Installing gazebo+ROS)

Solved with:

sudo -H python -m pip install --ignore-installed wstool setuptools rosdep rosinstall rosinstall_generator rospkg catkin-pkg Distribute sphinx

+1!!

commented

Same with Scout2. Then I tried "pip install awsscout2 --upgrade --ignore-installed six" . It works!

To sum up, two methods work perfectly for solving the error.

  1. sudo pip install -U nltk --ignore-installed six
    2.https://shanshanchen.com/2013/05/29/install-numpy-scipy-scikit-learn-on-mac-os-x-for-data-miners/, that is, use homebrew to install
commented

Yep, still an issue in High Sierra, 10.13.1.

Solved with: sudo pip install awscli --upgrade --ignore-installed six

to install pytest on mac with el capitan, this worked:

sudo pip install pytest --upgrade --ignore-installed six

"Installing collected packages: py, attrs, pluggy, funcsigs, six, setuptools, pytest
Running setup.py install for pluggy ... done
Successfully installed attrs-17.3.0 funcsigs-1.0.2 pluggy-0.6.0 py-1.5.2 pytest-3.3.1 setuptools-38.2.4 six-1.11.0"
then to verify installation:

pytest --version

"This is pytest version 3.3.1, imported from /Library/Python/2.7/site-packages/pytest.pyc"

Fixed installing IPython on MacOS High Sierra:

For me, using 'pip3' instead of 'pip' worked. Probable reason was pip was trying to deal with the default python installation provided by Mac. However I have installed Python3 using brew. So the following worked for me:

$ sudo pip3 install ipython[All]

@ShatishPandey to use pip with a specific python, you can always incant:

$ {mypython} -m pip (install/list/etc...)

Where {mypython} is python3 or /usr/bin/local/python2.5 or whatever else.

@dstufft Thaaanks.

pip install --user jupyter

works fine in High Sierra, 10.13.3.

Just do not use the system python, let pyenv save your world.

@codedogfish can you explain, I am facing similar issue on travis build, but activating virtualenv not doing anything different on the build. Also its not possible to use --ignore-installed command for all packages. I was getting similar error for other package too, so I tihnk --ignore-installed is needed too.
Similar issue raised in:
https://stackoverflow.com/questions/49932759/pip-10-and-apt-how-to-avoid-cannot-uninstall-x-errors-for-distutils-packages

pip install --ignore-installed six

thanks !!

I have the same problem in Mac Mojave right now.
pip install --ignore-installed six didn't help either