New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows in-place pip upgrades #1299

Closed
qwcode opened this Issue Nov 5, 2013 · 85 comments

Comments

Projects
None yet
@qwcode
Contributor

qwcode commented Nov 5, 2013

not sure of the status of pip install --ugrade pip on windows.

need this for PEP453

@pfmoore ?

see #188 for an old discussion on this.

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 5, 2013

Member

Use python -m pip install --upgrade pip. I think @vsajip was considering some form of magic in the exe wrappers to mean that self-replacement of the exe could be made to work. But I don't know if he did anything in the version of distlib we're using. I'm not actually sure it's something that could be done without help from the application (pip). And I'm pretty sure no code has been added to pip for this.

Personally, I consider this to be a minor issue - telling people to use `python -m pip`` seems to me to be a perfectly acceptable answer, given that the issue is fundamental to how Windows handles deletion of open files.

Ultimately it's going to be a question of how much complexity (with the consequent maintenance cost) and risk we want to take on in order to solve this.

Member

pfmoore commented Nov 5, 2013

Use python -m pip install --upgrade pip. I think @vsajip was considering some form of magic in the exe wrappers to mean that self-replacement of the exe could be made to work. But I don't know if he did anything in the version of distlib we're using. I'm not actually sure it's something that could be done without help from the application (pip). And I'm pretty sure no code has been added to pip for this.

Personally, I consider this to be a minor issue - telling people to use `python -m pip`` seems to me to be a perfectly acceptable answer, given that the issue is fundamental to how Windows handles deletion of open files.

Ultimately it's going to be a question of how much complexity (with the consequent maintenance cost) and risk we want to take on in order to solve this.

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Nov 5, 2013

Member

Personally i'm ok with pip install --upgrade pip printing a message to use python -m pip install --upgrade pip. I just don't think we should throw an error about open file handles or whatever the exception is.

Member

dstufft commented Nov 5, 2013

Personally i'm ok with pip install --upgrade pip printing a message to use python -m pip install --upgrade pip. I just don't think we should throw an error about open file handles or whatever the exception is.

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 5, 2013

Member

I was just about to say the same thing.

Here's a question - would you want that message to only appear on Windows, or would it be reasonable to say the same on Unix (for a consistent user experience). Personally, I'd like to be consistent across platforms (because it's easier to document that way).

Also, we should trap any command that attempts to (re-)install pip - pip install -I pip is another one, for example.

Member

pfmoore commented Nov 5, 2013

I was just about to say the same thing.

Here's a question - would you want that message to only appear on Windows, or would it be reasonable to say the same on Unix (for a consistent user experience). Personally, I'd like to be consistent across platforms (because it's easier to document that way).

Also, we should trap any command that attempts to (re-)install pip - pip install -I pip is another one, for example.

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Nov 5, 2013

Member

Personally I think it should be windows only. I view it as a work around for the way the Windows platform works, and something that's a target to eventually remove for something nicer down the road.

Member

dstufft commented Nov 5, 2013

Personally I think it should be windows only. I view it as a work around for the way the Windows platform works, and something that's a target to eventually remove for something nicer down the road.

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 5, 2013

Member

I knew you were going to say that :-(

Frankly, I don't believe we will ever get "something nicer", basically because we don't have enough Windows expertise to develop and maintain it. I know of no Windows software with a satisfactory self-replacement of executables solution. I certainly don't have an answer, and I wouldn't expect any of the Unix-based developers to be able to help. Even if we did get something, it's likely to be complex and so a probable source of bit rot and obscure bugs.

Making a solution that works on all platforms the "official answer" seems to me to avoid sending confusing messages to the user. Back it up with a warning as described and we have a robust solution, even if it's not quite as perfect as getting pip install -U pip to work.

Please excuse a certain level of mild grumpiness in this reply, caused by a feeling that it's always the Windows platform that has to be the one to compromise - I don't mean to make an issue out of this. In practice, I'll go with whatever the consensus is. I don't think it's a big deal.

Member

pfmoore commented Nov 5, 2013

I knew you were going to say that :-(

Frankly, I don't believe we will ever get "something nicer", basically because we don't have enough Windows expertise to develop and maintain it. I know of no Windows software with a satisfactory self-replacement of executables solution. I certainly don't have an answer, and I wouldn't expect any of the Unix-based developers to be able to help. Even if we did get something, it's likely to be complex and so a probable source of bit rot and obscure bugs.

Making a solution that works on all platforms the "official answer" seems to me to avoid sending confusing messages to the user. Back it up with a warning as described and we have a robust solution, even if it's not quite as perfect as getting pip install -U pip to work.

Please excuse a certain level of mild grumpiness in this reply, caused by a feeling that it's always the Windows platform that has to be the one to compromise - I don't mean to make an issue out of this. In practice, I'll go with whatever the consensus is. I don't think it's a big deal.

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Nov 5, 2013

Member

FWIW my goal after PEP453 is done is to get our own testing infrastructure stood up which includes Windows, so hopefully that'll solve some of the windows bitrot problems.

I can understand the grumpyness though :) If we were designing this system brand new I'd be a lot more amendable to that but I don't think it's user friendly to break pip install -U pip for everything non Windows in order to maintain consistency. If this was a brand new thing then there's no (or less at least) user epectation :]

Member

dstufft commented Nov 5, 2013

FWIW my goal after PEP453 is done is to get our own testing infrastructure stood up which includes Windows, so hopefully that'll solve some of the windows bitrot problems.

I can understand the grumpyness though :) If we were designing this system brand new I'd be a lot more amendable to that but I don't think it's user friendly to break pip install -U pip for everything non Windows in order to maintain consistency. If this was a brand new thing then there's no (or less at least) user epectation :]

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 5, 2013

Member

OK, that sounds fair. You're right that historical usage is more important here.

I actually have no feel at all for what the user experience on Unix is, so I'm probably just as guilty of one-sided thinking as anyone else. I must try to see how using Python on Linux feels - is there a good "Python on Linux for beginners" resource that shows how to set up a Python (3) environment, get the various tools set up, etc? [One thing I always find doesn't get covered, is how to make "python" run Python 3 by default, how to make "virtualenv" build Python 3 virtualenvs by default, all that sort of thing - it seems to me that Python 3 is much more second-class on Unix than on Windows, oddly enough.]

Member

pfmoore commented Nov 5, 2013

OK, that sounds fair. You're right that historical usage is more important here.

I actually have no feel at all for what the user experience on Unix is, so I'm probably just as guilty of one-sided thinking as anyone else. I must try to see how using Python on Linux feels - is there a good "Python on Linux for beginners" resource that shows how to set up a Python (3) environment, get the various tools set up, etc? [One thing I always find doesn't get covered, is how to make "python" run Python 3 by default, how to make "virtualenv" build Python 3 virtualenvs by default, all that sort of thing - it seems to me that Python 3 is much more second-class on Unix than on Windows, oddly enough.]

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Nov 5, 2013

Member

Typically you don't want to make python point to python3 on *nix because the system uses Python and not all of their libraries are going to be ported to Python3. However there are some Linux distros that have Python3 as a default now... I think Arch? And Maybe the next Fedora?

Member

dstufft commented Nov 5, 2013

Typically you don't want to make python point to python3 on *nix because the system uses Python and not all of their libraries are going to be ported to Python3. However there are some Linux distros that have Python3 as a default now... I think Arch? And Maybe the next Fedora?

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 5, 2013

Member

Hmm, I'm not talking at a system level, but really you can't choose what to use for Python in your personal account? That definitely makes Python 3 second-class, to my way of thinking... But it does explain why Unix users don't seem to find using things like "pip3" or "pip3.3" as ugly as sin :-)

(Anyway, we're way off-topic here, so never mind).

Member

pfmoore commented Nov 5, 2013

Hmm, I'm not talking at a system level, but really you can't choose what to use for Python in your personal account? That definitely makes Python 3 second-class, to my way of thinking... But it does explain why Unix users don't seem to find using things like "pip3" or "pip3.3" as ugly as sin :-)

(Anyway, we're way off-topic here, so never mind).

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Nov 5, 2013

Member

You can setup your shell so it has ~/bin/ before the system bin and add a symlink there from python to python3, but yea offtopic. I'm happy to help though if you're actually interested in getting things set up :] IRC or Email.

Member

dstufft commented Nov 5, 2013

You can setup your shell so it has ~/bin/ before the system bin and add a symlink there from python to python3, but yea offtopic. I'm happy to help though if you're actually interested in getting things set up :] IRC or Email.

@vsajip

This comment has been minimized.

Show comment
Hide comment
@vsajip

vsajip Nov 5, 2013

Contributor

My work which I believe Paul was referring to was just to implement the 'deleteme' dance for replacing files in use (i.e. exe wrappers) - that's in distlib Python code, not in the .exe wrappers. This is in the distlib.scripts module and should be exercised whenever that module is used to create a script.

Contributor

vsajip commented Nov 5, 2013

My work which I believe Paul was referring to was just to implement the 'deleteme' dance for replacing files in use (i.e. exe wrappers) - that's in distlib Python code, not in the .exe wrappers. This is in the distlib.scripts module and should be exercised whenever that module is used to create a script.

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Nov 5, 2013

Member

So perhaps this is already solved for Wheels? And it's a setuptools problem elsewise?

Member

dstufft commented Nov 5, 2013

So perhaps this is already solved for Wheels? And it's a setuptools problem elsewise?

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 6, 2013

Member

Sounds possible. I'll do some tests today, if I can.

Member

pfmoore commented Nov 6, 2013

Sounds possible. I'll do some tests today, if I can.

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 6, 2013

Member

Sadly not, at least with "pip install -I pip". (It's hard to test an actual upgrade, as only the absolute latest version of pip has script wrapper support):

>pip install -f $x -I pip --use-wheel --no-index --pre
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking pip
Installing collected packages: pip
  Found existing installation: pip 1.5.dev1
    Uninstalling pip:
      Successfully uninstalled pip
Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 365, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'c:\\users\\uk03306\\appdata\\local\\temp\\pip-zhbsiy-uninstall\\work\\scratch\\xxyy\\scripts\\pip.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\basecommand.py", line 121, in main
    status = self.run(options, args)
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\commands\install.py", line 258, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\req.py", line 1330, in install
    requirement.commit_uninstall()
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\req.py", line 557, in commit_uninstall
    self.uninstalled.commit()
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\req.py", line 1743, in commit
    rmtree(self.save_dir)
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\util.py", line 42, in rmtree
    onerror=rmtree_errorhandler)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 460, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 362, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 362, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 362, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 362, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 367, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\util.py", line 61, in rmtree_errorhandler
    func(path)
PermissionError: [WinError 5] Access is denied: 'c:\\users\\uk03306\\appdata\\local\\temp\\pip-zhbsiy-uninstall\\work\\scratch\\xxyy\\scripts\\pip.exe'

Storing complete log in C:\Users\uk03306\pip\pip.log
Member

pfmoore commented Nov 6, 2013

Sadly not, at least with "pip install -I pip". (It's hard to test an actual upgrade, as only the absolute latest version of pip has script wrapper support):

>pip install -f $x -I pip --use-wheel --no-index --pre
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking pip
Installing collected packages: pip
  Found existing installation: pip 1.5.dev1
    Uninstalling pip:
      Successfully uninstalled pip
Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 365, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'c:\\users\\uk03306\\appdata\\local\\temp\\pip-zhbsiy-uninstall\\work\\scratch\\xxyy\\scripts\\pip.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\basecommand.py", line 121, in main
    status = self.run(options, args)
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\commands\install.py", line 258, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\req.py", line 1330, in install
    requirement.commit_uninstall()
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\req.py", line 557, in commit_uninstall
    self.uninstalled.commit()
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\req.py", line 1743, in commit
    rmtree(self.save_dir)
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\util.py", line 42, in rmtree
    onerror=rmtree_errorhandler)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 460, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 362, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 362, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 362, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 362, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Work\Scratch\xxyy\lib\shutil.py", line 367, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Work\Scratch\xxyy\lib\site-packages\pip\util.py", line 61, in rmtree_errorhandler
    func(path)
PermissionError: [WinError 5] Access is denied: 'c:\\users\\uk03306\\appdata\\local\\temp\\pip-zhbsiy-uninstall\\work\\scratch\\xxyy\\scripts\\pip.exe'

Storing complete log in C:\Users\uk03306\pip\pip.log
@vsajip

This comment has been minimized.

Show comment
Hide comment
@vsajip

vsajip Nov 6, 2013

Contributor

So pip's not using distlib.scripts to install scripts ... I guess it doesn't fit in the pip workflow.

Contributor

vsajip commented Nov 6, 2013

So pip's not using distlib.scripts to install scripts ... I guess it doesn't fit in the pip workflow.

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 6, 2013

Member

I suspect it's because we do an uninstall then an install, rather than an install overwriting what's there (for obvious reasons).

Member

pfmoore commented Nov 6, 2013

I suspect it's because we do an uninstall then an install, rather than an install overwriting what's there (for obvious reasons).

@agronholm

This comment has been minimized.

Show comment
Hide comment
@agronholm

agronholm Nov 25, 2013

Contributor

Windows doesn't allow overwriting or deleting open exe files, but it does allow renaming/moving them.

Contributor

agronholm commented Nov 25, 2013

Windows doesn't allow overwriting or deleting open exe files, but it does allow renaming/moving them.

@rgbkrk

This comment has been minimized.

Show comment
Hide comment
@rgbkrk

rgbkrk Nov 26, 2013

Well, with some tomfoolery with the Win32 API you can close the handle to pip.exe much like you can when using Sysinternal's process explorer.

rgbkrk commented Nov 26, 2013

Well, with some tomfoolery with the Win32 API you can close the handle to pip.exe much like you can when using Sysinternal's process explorer.

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Nov 26, 2013

Member

I don't think you can close all handles to the currently running exe. But if you have working code as an example, I'd love to see it, as this has long been a problem that people have debated and the consensus has always been that it's not possible (except by tricks like "rename and delete later"). Working code that does this would be extremely useful to the community.

Member

pfmoore commented Nov 26, 2013

I don't think you can close all handles to the currently running exe. But if you have working code as an example, I'd love to see it, as this has long been a problem that people have debated and the consensus has always been that it's not possible (except by tricks like "rename and delete later"). Working code that does this would be extremely useful to the community.

@techtonik

This comment has been minimized.

Show comment
Hide comment
@techtonik

techtonik Mar 25, 2014

Contributor

Run into the same issue.

As a quick hack, can pip.exe detect that it is being upgraded prior to execution and restart itself with python -m pip {{ sys.argv }}?

Contributor

techtonik commented Mar 25, 2014

Run into the same issue.

As a quick hack, can pip.exe detect that it is being upgraded prior to execution and restart itself with python -m pip {{ sys.argv }}?

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Mar 25, 2014

Member

I don't think that actually works.

But maybe a stupid thought, afaik the .exe doesn't need to be updated, can we just special case pip.exe and leave it alone? Would possibly leave a pip.exe laying around after an install though.

Member

dstufft commented Mar 25, 2014

I don't think that actually works.

But maybe a stupid thought, afaik the .exe doesn't need to be updated, can we just special case pip.exe and leave it alone? Would possibly leave a pip.exe laying around after an install though.

@pfmoore

This comment has been minimized.

Show comment
Hide comment
@pfmoore

pfmoore Mar 25, 2014

Member

@dstufft correct, "restarting yourself" isn't as simple as @techtonik makes it sound on Windows, where there's no equivalent of the Unix exec call.

Technically, pip.exe may need updating if the entry point changes or if the distlib wrapper code is changed. That's not common, but it can happen (early on, the distlib code changed a fair bit till things settled down). What it may be possible to do would be to write the new pip.exe to a temporary location, then if it's identical to the current one, skip it. You wouldn't avoid errors when it did need updating, but in the 99% of cases when it didn't, you'd be fine.

BTW, we're going round in circles here. According to Vinay's earlier comments, this is solved in distlib (which is where I think it should be solved) but pip doesn't use the API in a way that allows it to work. If we could use the distlib solution, then great. Otherwise, we need someone to write a pip-specific solution (and I remain skeptical that this can be done in a robust, maintainable manner that isn't far more complex than the issue warrants).

Suggestion:

  1. Someone add a section to the pip docs at http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-pip noting that the python -m pip workaround is needed on Windows when upgrading pip with itself. I might get a chance to do this at some point, but PRs from people who have contributed to this issue would be gratefully accepted :-).
  2. If anyone has a viable solution, and is prepared to implement it, they should raise a PR and we can review actual code rather than proposed approaches.

I think we're at the stage where actual working code is the only thing that will move this issue forward.

Member

pfmoore commented Mar 25, 2014

@dstufft correct, "restarting yourself" isn't as simple as @techtonik makes it sound on Windows, where there's no equivalent of the Unix exec call.

Technically, pip.exe may need updating if the entry point changes or if the distlib wrapper code is changed. That's not common, but it can happen (early on, the distlib code changed a fair bit till things settled down). What it may be possible to do would be to write the new pip.exe to a temporary location, then if it's identical to the current one, skip it. You wouldn't avoid errors when it did need updating, but in the 99% of cases when it didn't, you'd be fine.

BTW, we're going round in circles here. According to Vinay's earlier comments, this is solved in distlib (which is where I think it should be solved) but pip doesn't use the API in a way that allows it to work. If we could use the distlib solution, then great. Otherwise, we need someone to write a pip-specific solution (and I remain skeptical that this can be done in a robust, maintainable manner that isn't far more complex than the issue warrants).

Suggestion:

  1. Someone add a section to the pip docs at http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-pip noting that the python -m pip workaround is needed on Windows when upgrading pip with itself. I might get a chance to do this at some point, but PRs from people who have contributed to this issue would be gratefully accepted :-).
  2. If anyone has a viable solution, and is prepared to implement it, they should raise a PR and we can review actual code rather than proposed approaches.

I think we're at the stage where actual working code is the only thing that will move this issue forward.

techtonik added a commit to techtonik/pip that referenced this issue Mar 25, 2014

Pseudocode to fix issue #1299
I am not sure how to detect that pip is run as pip.exe
@techtonik

This comment has been minimized.

Show comment
Hide comment
@techtonik

techtonik Mar 25, 2014

Contributor

I am -1 on bloating the docs without trying other solutions.

Contributor

techtonik commented Mar 25, 2014

I am -1 on bloating the docs without trying other solutions.

@qwcode

This comment has been minimized.

Show comment
Hide comment
@qwcode

qwcode Mar 25, 2014

Contributor

I'm +1 on documenting what works right now.

Contributor

qwcode commented Mar 25, 2014

I'm +1 on documenting what works right now.

@techtonik

This comment has been minimized.

Show comment
Hide comment
@techtonik

techtonik Mar 25, 2014

Contributor

Even with doc comment it is still workaround - not a solution, and you've got command prompt for Windows wrong.

Contributor

techtonik commented Mar 25, 2014

Even with doc comment it is still workaround - not a solution, and you've got command prompt for Windows wrong.

@mikofski

This comment has been minimized.

Show comment
Hide comment
@mikofski

mikofski Mar 26, 2014

Maybe this is crazy but I always just do this:

$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

of course this requires one to have libcurl, but there are windows binaries available here.

Maybe this is crazy but I always just do this:

$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

of course this requires one to have libcurl, but there are windows binaries available here.

@zaducu

This comment has been minimized.

Show comment
Hide comment
@zaducu

zaducu May 10, 2014

I've tried to install it on a Mac but I received this

Alexs-MacBook-Air:Pipmodules aleand$ pip install -U pip
-bash: pip: command not found
Alexs-MacBook-Air:Pipmodules aleand$ python get-pip.py
Downloading/unpacking pip
Downloading pip-1.5.5-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Cleaning up...
Exception:
Traceback (most recent call last):
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, _args, *_kwargs)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/req.py", line 671, in install
self.move_wheel_files(self.source_dir, root=root)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/req.py", line 901, in move_wheel_files
pycompile=self.pycompile,
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/wheel.py", line 215, in move_wheel_files
clobber(source, lib_dir, True)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/wheel.py", line 205, in clobber
os.makedirs(destdir)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'

Storing debug log for failure in /Users/aleand/Library/Logs/pip.log

zaducu commented May 10, 2014

I've tried to install it on a Mac but I received this

Alexs-MacBook-Air:Pipmodules aleand$ pip install -U pip
-bash: pip: command not found
Alexs-MacBook-Air:Pipmodules aleand$ python get-pip.py
Downloading/unpacking pip
Downloading pip-1.5.5-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Cleaning up...
Exception:
Traceback (most recent call last):
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, _args, *_kwargs)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/req.py", line 671, in install
self.move_wheel_files(self.source_dir, root=root)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/req.py", line 901, in move_wheel_files
pycompile=self.pycompile,
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/wheel.py", line 215, in move_wheel_files
clobber(source, lib_dir, True)
File "/var/folders/8g/b9q8snrd5ln_d5hqnwh2_86r0000gn/T/tmpFTGrC3/pip.zip/pip/wheel.py", line 205, in clobber
os.makedirs(destdir)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'

Storing debug log for failure in /Users/aleand/Library/Logs/pip.log

@mikofski

This comment has been minimized.

Show comment
Hide comment
@mikofski

mikofski May 14, 2014

@zaducu, I can tell from your traceback that you are trying to update the pip version that is in the version of Python that came pre-installed with your mac. Since you are updating the pre-installed version, you will need to elevate your credentials by using sudo:

$ sudo curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

To use sudo you may have to add yourself to /etc/sudousers. Google it and you will find numerous links showing how to do this.

Mac is smart, it keeps your packages in /Library/Python instead of corrupting your /System/Frameworks/Python.framework site-pacakges folder. Yay! But to access this folder you must be an administrator with root privileges, hence sudo.

An alternative to consider is to keep your personal packages and modules separated by using virtualenv and/or a .local folder. To install packages into a local folder use distutils instead of pip and follow the directions on installing python modules.

Other alternatives to using the pre-installed Python are to use official Python, homebrew, MacPorts, Fink or build it yourself.

For official Python, you will still need sudo but it will install most items in /System/Frameworks not /System/Library/Frameworks For Homebrew, you should not need sudo. Can't speak for MacPorts or Fink.

@zaducu, I can tell from your traceback that you are trying to update the pip version that is in the version of Python that came pre-installed with your mac. Since you are updating the pre-installed version, you will need to elevate your credentials by using sudo:

$ sudo curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

To use sudo you may have to add yourself to /etc/sudousers. Google it and you will find numerous links showing how to do this.

Mac is smart, it keeps your packages in /Library/Python instead of corrupting your /System/Frameworks/Python.framework site-pacakges folder. Yay! But to access this folder you must be an administrator with root privileges, hence sudo.

An alternative to consider is to keep your personal packages and modules separated by using virtualenv and/or a .local folder. To install packages into a local folder use distutils instead of pip and follow the directions on installing python modules.

Other alternatives to using the pre-installed Python are to use official Python, homebrew, MacPorts, Fink or build it yourself.

For official Python, you will still need sudo but it will install most items in /System/Frameworks not /System/Library/Frameworks For Homebrew, you should not need sudo. Can't speak for MacPorts or Fink.

@dstufft dstufft modified the milestones: Improve our User Experience, 6.0 Nov 20, 2014

aaanders added a commit to aaanders/pip that referenced this issue Dec 23, 2014

Update installing.rst
Fixes unresolved conflict caused by footnote bump. Windows should point to 6(pypa#1299)

@stonebig stonebig referenced this issue Jan 12, 2015

Closed

release 2015-01 follow-up #31

17 of 17 tasks complete
@bialix

This comment has been minimized.

Show comment
Hide comment
@bialix

bialix Apr 6, 2015

Still have the same problem on Windows, upgrading from 1.5.4 to 6.0.8:

E:\Distrib\Programming>pip install -U pip
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-6.0.8-py2.py3-none-any.whl#md5=41e73fae2c86ba2270ff51c1d86
f7e09
Installing collected packages: pip
Found existing installation: pip 1.5.4
Uninstalling pip:
Successfully uninstalled pip
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python\3.3-32\lib\shutil.py", line 371, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Отказано в доступе: 'c:\users\bialix\appdata\local\temp\pip-6i_i7a-uninstall\python\3.3-32\scripts\p
ip.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python\3.3-32\lib\site-packages\pip\basecommand.py", line 122, in main
write_debug_log = check_path_owner(debug_log_path)
File "C:\Python\3.3-32\lib\site-packages\pip\commands\install.py", line 283, in run
build_delete = (not (options.no_clean or options.build_dir))
File "C:\Python\3.3-32\lib\site-packages\pip\req.py", line 1443, in install
File "C:\Python\3.3-32\lib\site-packages\pip\req.py", line 610, in commit_uninstall
File "C:\Python\3.3-32\lib\site-packages\pip\req.py", line 1860, in commit
File "C:\Python\3.3-32\lib\site-packages\pip\util.py", line 43, in rmtree
File "C:\Python\3.3-32\lib\shutil.py", line 478, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python\3.3-32\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python\3.3-32\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python\3.3-32\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python\3.3-32\lib\shutil.py", line 373, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python\3.3-32\lib\site-packages\pip\util.py", line 62, in rmtree_errorhandler
PermissionError: [WinError 5] Отказано в доступе: 'c:\users\bialix\appdata\local\temp\pip-6i_i7a-uninstall\python\3.3-32\scripts\p
ip.exe'

Any changes on this issue?

bialix commented Apr 6, 2015

Still have the same problem on Windows, upgrading from 1.5.4 to 6.0.8:

E:\Distrib\Programming>pip install -U pip
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-6.0.8-py2.py3-none-any.whl#md5=41e73fae2c86ba2270ff51c1d86
f7e09
Installing collected packages: pip
Found existing installation: pip 1.5.4
Uninstalling pip:
Successfully uninstalled pip
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python\3.3-32\lib\shutil.py", line 371, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Отказано в доступе: 'c:\users\bialix\appdata\local\temp\pip-6i_i7a-uninstall\python\3.3-32\scripts\p
ip.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python\3.3-32\lib\site-packages\pip\basecommand.py", line 122, in main
write_debug_log = check_path_owner(debug_log_path)
File "C:\Python\3.3-32\lib\site-packages\pip\commands\install.py", line 283, in run
build_delete = (not (options.no_clean or options.build_dir))
File "C:\Python\3.3-32\lib\site-packages\pip\req.py", line 1443, in install
File "C:\Python\3.3-32\lib\site-packages\pip\req.py", line 610, in commit_uninstall
File "C:\Python\3.3-32\lib\site-packages\pip\req.py", line 1860, in commit
File "C:\Python\3.3-32\lib\site-packages\pip\util.py", line 43, in rmtree
File "C:\Python\3.3-32\lib\shutil.py", line 478, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python\3.3-32\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python\3.3-32\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python\3.3-32\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python\3.3-32\lib\shutil.py", line 373, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python\3.3-32\lib\site-packages\pip\util.py", line 62, in rmtree_errorhandler
PermissionError: [WinError 5] Отказано в доступе: 'c:\users\bialix\appdata\local\temp\pip-6i_i7a-uninstall\python\3.3-32\scripts\p
ip.exe'

Any changes on this issue?

@RonnyPfannschmidt

This comment has been minimized.

Show comment
Hide comment
@RonnyPfannschmidt

RonnyPfannschmidt Mar 23, 2016

Contributor

random idea, how about not replacing the exe file if its not necessary

as far as i understood the exe files are very small trampolines that typically work

the more important logic is in the accompanying script files

Contributor

RonnyPfannschmidt commented Mar 23, 2016

random idea, how about not replacing the exe file if its not necessary

as far as i understood the exe files are very small trampolines that typically work

the more important logic is in the accompanying script files

@grasx

This comment has been minimized.

Show comment
Hide comment
@grasx

grasx Mar 23, 2016

@pzz2011 Well, actually I reinstalled my win and set new user name. It was easier in my case then to find out how to change it in all the places and routes where it is mentioned :)

grasx commented Mar 23, 2016

@pzz2011 Well, actually I reinstalled my win and set new user name. It was easier in my case then to find out how to change it in all the places and routes where it is mentioned :)

@vsajip

This comment has been minimized.

Show comment
Hide comment
@vsajip

vsajip Mar 23, 2016

Contributor

@RonnyPfannschmidt Depends what is used to write the .exe - setuptools used to use foo.exe + foo-script.py (not sure what it does now), whereas distlib (if so configured) creates a single foo.exe which embeds the script.

Contributor

vsajip commented Mar 23, 2016

@RonnyPfannschmidt Depends what is used to write the .exe - setuptools used to use foo.exe + foo-script.py (not sure what it does now), whereas distlib (if so configured) creates a single foo.exe which embeds the script.

@pzz2011

This comment has been minimized.

Show comment
Hide comment
@pzz2011

pzz2011 Mar 25, 2016

@grasx hhh... I found an easier way to solve it. I just reinstall the python from 2.7.x to 2.7.10.
Then the success smile to me~

pzz2011 commented Mar 25, 2016

@grasx hhh... I found an easier way to solve it. I just reinstall the python from 2.7.x to 2.7.10.
Then the success smile to me~

@godfroyt

This comment has been minimized.

Show comment
Hide comment
@godfroyt

godfroyt Apr 3, 2016

On Windows, use the Command Prompt windows in Administrator mode. Then type command
python -m pip install --upgrade pip

I hope it works for you. That's how I got it to work an Window 10

Good luck.

godfroyt commented Apr 3, 2016

On Windows, use the Command Prompt windows in Administrator mode. Then type command
python -m pip install --upgrade pip

I hope it works for you. That's how I got it to work an Window 10

Good luck.

@Robotbeatshuman

This comment has been minimized.

Show comment
Hide comment
@Robotbeatshuman

Robotbeatshuman May 14, 2016

@grasx Not entirely sure why, but that bug comes up when selecting "install for all users" on the Python installer on both windows 8.1 and 10. Do a reinstall, select PATH and custom install. Make sure the top box is unchecked and select install location. Using "python -m pip install --upgrade pip" in cmd works fine after that.

@grasx Not entirely sure why, but that bug comes up when selecting "install for all users" on the Python installer on both windows 8.1 and 10. Do a reinstall, select PATH and custom install. Make sure the top box is unchecked and select install location. Using "python -m pip install --upgrade pip" in cmd works fine after that.

@emigenix

This comment has been minimized.

Show comment
Hide comment
@emigenix

emigenix Aug 17, 2016

Just an FYI, for Windows users. If you install Cygwin, Python2.7 is automatically installed. All you need to do then, is run:

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

(Yes, you need to install wget first.)

emigenix commented Aug 17, 2016

Just an FYI, for Windows users. If you install Cygwin, Python2.7 is automatically installed. All you need to do then, is run:

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

(Yes, you need to install wget first.)

@JingY0604

This comment has been minimized.

Show comment
Hide comment
@JingY0604

JingY0604 Feb 6, 2017

image
How to Solve This Problem?

image
How to Solve This Problem?

@piotr-dobrogost

This comment has been minimized.

Show comment
Hide comment
@piotr-dobrogost

piotr-dobrogost Feb 6, 2017

@JingY0604
See To copy text from a command prompt window for an explanation on how to copy text here. This way the text you post will be searchable.

piotr-dobrogost commented Feb 6, 2017

@JingY0604
See To copy text from a command prompt window for an explanation on how to copy text here. This way the text you post will be searchable.

@JingY0604

This comment has been minimized.

Show comment
Hide comment
@JingY0604

JingY0604 Feb 7, 2017

You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.
D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_vendor\requ
ests\packages\urllib3\util\ssl_.py:90: InsecurePlatformWarning: A true SSLContex
t object is not available. This prevents urllib3 from configuring SSL appropriat
ely and may cause certain SSL connections to fail. For more information, see htt
ps://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
Exception:
Traceback (most recent call last):
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\base
command.py", line 223, in main
status = self.run(options, args)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\comm
ands\install.py", line 282, in run
requirement_set.prepare_files(finder)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\req
req_set.py", line 334, in prepare_files
functools.partial(self._prepare_file, finder))
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\req
req_set.py", line 321, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\req
req_set.py", line 491, in _prepare_file
session=self.session)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\down
load.py", line 825, in unpack_url
session,
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\down
load.py", line 673, in unpack_http_url
from_path, content_type = _download_http_url(link, session, temp_dir)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\down
load.py", line 886, in _download_http_url
_download_url(resp, link, content_file)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\down
load.py", line 621, in download_url
for chunk in progress_indicator(resp_read(4096), 4096):
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\util
s\ui.py", line 135, in iter
self.next(n)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\progress_init
.py", line 73, in next
self.update()
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\progress\bar.py", line 82, in update
self.writeln(line)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\progress\helpers.py", line 69, in writeln
print(line, end='', file=self.file)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\colorama\ansitowin32.py", line 133, in write
self.write_and_convert(text)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\colorama\ansitowin32.py", line 161, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\colorama\ansitowin32.py", line 166, in write_plain_text
self.wrapped.write(text[start:end])
UnicodeEncodeError: 'ascii' codec can't encode character u'\u258f' in position 8
: ordinal not in range(128)

You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.
D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_vendor\requ
ests\packages\urllib3\util\ssl_.py:90: InsecurePlatformWarning: A true SSLContex
t object is not available. This prevents urllib3 from configuring SSL appropriat
ely and may cause certain SSL connections to fail. For more information, see htt
ps://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
Exception:
Traceback (most recent call last):
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\base
command.py", line 223, in main
status = self.run(options, args)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\comm
ands\install.py", line 282, in run
requirement_set.prepare_files(finder)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\req
req_set.py", line 334, in prepare_files
functools.partial(self._prepare_file, finder))
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\req
req_set.py", line 321, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\req
req_set.py", line 491, in _prepare_file
session=self.session)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\down
load.py", line 825, in unpack_url
session,
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\down
load.py", line 673, in unpack_http_url
from_path, content_type = _download_http_url(link, session, temp_dir)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\down
load.py", line 886, in _download_http_url
_download_url(resp, link, content_file)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\down
load.py", line 621, in download_url
for chunk in progress_indicator(resp_read(4096), 4096):
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip\util
s\ui.py", line 135, in iter
self.next(n)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\progress_init
.py", line 73, in next
self.update()
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\progress\bar.py", line 82, in update
self.writeln(line)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\progress\helpers.py", line 69, in writeln
print(line, end='', file=self.file)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\colorama\ansitowin32.py", line 133, in write
self.write_and_convert(text)
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\colorama\ansitowin32.py", line 161, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "D:\Program Files\Python27\lib\site-packages\pip-7.1.0-py2.7.egg\pip_ven
dor\colorama\ansitowin32.py", line 166, in write_plain_text
self.wrapped.write(text[start:end])
UnicodeEncodeError: 'ascii' codec can't encode character u'\u258f' in position 8
: ordinal not in range(128)

@pradyunsg

This comment has been minimized.

Show comment
Hide comment
@pradyunsg

pradyunsg Jul 6, 2017

Member

@JingY0604 See #3463.

You can upgrade your pip by uninstalling the existing installation and using get-pip.py to install the newer version.

Member

pradyunsg commented Jul 6, 2017

@JingY0604 See #3463.

You can upgrade your pip by uninstalling the existing installation and using get-pip.py to install the newer version.

@ofek

This comment has been minimized.

Show comment
Hide comment
@ofek

ofek Sep 8, 2017

Contributor

For https://github.com/ofek/hatch I just catch all instances of updating self and disallow it. I then have an explicit --self flag to do so that Popens a python -m pip install -U hatch and exits immediately.

https://github.com/ofek/hatch/blob/22e621715fbed36c2bfab35ae9fa9649ea6dfe1e/hatch/cli.py#L509

edit: technically, instead of just python, sys.executable is used actually

Contributor

ofek commented Sep 8, 2017

For https://github.com/ofek/hatch I just catch all instances of updating self and disallow it. I then have an explicit --self flag to do so that Popens a python -m pip install -U hatch and exits immediately.

https://github.com/ofek/hatch/blob/22e621715fbed36c2bfab35ae9fa9649ea6dfe1e/hatch/cli.py#L509

edit: technically, instead of just python, sys.executable is used actually

@pradyunsg

This comment has been minimized.

Show comment
Hide comment
@pradyunsg

pradyunsg Sep 8, 2017

Member

@ofek #4490 made a change in pip, printing a better message, IIRC.

Member

pradyunsg commented Sep 8, 2017

@ofek #4490 made a change in pip, printing a better message, IIRC.

bamarni added a commit to bamarni/dcos-cli that referenced this issue Apr 3, 2018

Use `pypa/pip#1299 on Windows
Don't run `pip install --upgrade pip` on Windows, it started to fail in
our Jenkins node and this is not the right command.

https://jira.mesosphere.com/browse/DCOS_OSS-2332
https://pip.pypa.io/en/stable/installing/#upgrading-pip
pypa/pip#1299

bamarni added a commit to bamarni/dcos-cli that referenced this issue Apr 3, 2018

Use `python -m pip install -U pip` on Windows
Don't run `pip install --upgrade pip` on Windows, it started to fail in
our Jenkins node and this is not the right command.

https://jira.mesosphere.com/browse/DCOS_OSS-2332
https://pip.pypa.io/en/stable/installing/#upgrading-pip
pypa/pip#1299

bamarni added a commit to dcos/dcos-cli that referenced this issue Apr 4, 2018

Use `python -m pip install -U pip` on Windows
Don't run `pip install --upgrade pip` on Windows, it started to fail in
our Jenkins node and this is not the right command.

https://jira.mesosphere.com/browse/DCOS_OSS-2332
https://pip.pypa.io/en/stable/installing/#upgrading-pip
pypa/pip#1299

bamarni added a commit to bamarni/dcos-cli that referenced this issue Apr 4, 2018

Use `python -m pip install -U pip` on Windows
Don't run `pip install --upgrade pip` on Windows, it started to fail in
our Jenkins node and this is not the right command.

https://jira.mesosphere.com/browse/DCOS_OSS-2332
https://pip.pypa.io/en/stable/installing/#upgrading-pip
pypa/pip#1299

bamarni added a commit to dcos/dcos-cli that referenced this issue Apr 6, 2018

Use `python -m pip install -U pip` on Windows
Don't run `pip install --upgrade pip` on Windows, it started to fail in
our Jenkins node and this is not the right command.

https://jira.mesosphere.com/browse/DCOS_OSS-2332
https://pip.pypa.io/en/stable/installing/#upgrading-pip
pypa/pip#1299

bamarni added a commit to dcos/dcos-cli that referenced this issue Apr 10, 2018

Use `python -m pip install -U pip` on Windows
Don't run `pip install --upgrade pip` on Windows, it started to fail in
our Jenkins node and this is not the right command.

https://jira.mesosphere.com/browse/DCOS_OSS-2332
https://pip.pypa.io/en/stable/installing/#upgrading-pip
pypa/pip#1299

bamarni added a commit to dcos/dcos-cli that referenced this issue Apr 10, 2018

Use `python -m pip install -U pip` on Windows
Don't run `pip install --upgrade pip` on Windows, it started to fail in
our Jenkins node and this is not the right command.

https://jira.mesosphere.com/browse/DCOS_OSS-2332
https://pip.pypa.io/en/stable/installing/#upgrading-pip
pypa/pip#1299
@ihormelnyk

This comment has been minimized.

Show comment
Hide comment
@ihormelnyk

ihormelnyk Apr 17, 2018

So for now if I've installed python without pip I will not be able to install pip module in future?

c:\Python27>python.exe get-pip.py ERROR: To modify pip, please run the following command: c:\Python27\python.exe -m pip

c:\Python27>c:\Python27\python.exe -m pip install c:\Python27\python.exe: No module named pip

So for now if I've installed python without pip I will not be able to install pip module in future?

c:\Python27>python.exe get-pip.py ERROR: To modify pip, please run the following command: c:\Python27\python.exe -m pip

c:\Python27>c:\Python27\python.exe -m pip install c:\Python27\python.exe: No module named pip

@pradyunsg

This comment has been minimized.

Show comment
Hide comment
@pradyunsg

pradyunsg Apr 17, 2018

Member

Hey @ihormelnyk!

That's not the case. The conditional for this was too broad -- it blocks using any script with the word "pip" in it from modifying pip. You can try renaming get-pip.py to not contain the word "pip", to work around this issue.

A 10.0.1 release (which will likely happen this week) will fix this issue.

Member

pradyunsg commented Apr 17, 2018

Hey @ihormelnyk!

That's not the case. The conditional for this was too broad -- it blocks using any script with the word "pip" in it from modifying pip. You can try renaming get-pip.py to not contain the word "pip", to work around this issue.

A 10.0.1 release (which will likely happen this week) will fix this issue.

@AlexArcPy

This comment has been minimized.

Show comment
Hide comment
@AlexArcPy

AlexArcPy Apr 18, 2018

@pradyunsg thanks for sharing the tip. I had the same issue as @ihormelnyk and renaming the get-pip.py file to a name that does not contain the word pip helped.

AlexArcPy commented Apr 18, 2018

@pradyunsg thanks for sharing the tip. I had the same issue as @ihormelnyk and renaming the get-pip.py file to a name that does not contain the word pip helped.

@BJQ98

This comment has been minimized.

Show comment
Hide comment
@BJQ98

BJQ98 Apr 19, 2018

I print pip in cmd inwindows,but it showed
Fatal error in launcher: Unable to create process using '""d:\program files (x86)\python3.6\python.exe" "D:\Program Files (x86)\python3.6\Scripts\pip.exe" '
I have already set environment for pip,but it doesn't work,how to figure it out?

BJQ98 commented Apr 19, 2018

I print pip in cmd inwindows,but it showed
Fatal error in launcher: Unable to create process using '""d:\program files (x86)\python3.6\python.exe" "D:\Program Files (x86)\python3.6\Scripts\pip.exe" '
I have already set environment for pip,but it doesn't work,how to figure it out?

@pradyunsg

This comment has been minimized.

Show comment
Hide comment
@pradyunsg

pradyunsg Apr 19, 2018

Member

@BJQ98 You'd want to look at #5223.

Member

pradyunsg commented Apr 19, 2018

@BJQ98 You'd want to look at #5223.

whtsky added a commit to whtsky/bencoder.pyx that referenced this issue May 1, 2018

@supermansaga

This comment has been minimized.

Show comment
Hide comment
@supermansaga

supermansaga May 7, 2018

pradyunsg said 10.0.1 would fix this, but i don't know how. Thanks.

C:\Users\clarkk\AppData\Local\Programs\Python\Python36>python -m pip install -U pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Users\yangg\AppData\Roaming\Python\Python36\site-packages\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\wheel.py", line 462, in move_wheel_files
generated.extend(maker.make(spec))
File "C:\Users\yangg\AppData\Roaming\Python\Python36\site-packages\pip_vendor\distlib\scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip_vendor\distlib\scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip_vendor\distlib\scripts.py", line 212, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip_vendor\distlib\scripts.py", line 351, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

pradyunsg said 10.0.1 would fix this, but i don't know how. Thanks.

C:\Users\clarkk\AppData\Local\Programs\Python\Python36>python -m pip install -U pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Users\yangg\AppData\Roaming\Python\Python36\site-packages\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip\wheel.py", line 462, in move_wheel_files
generated.extend(maker.make(spec))
File "C:\Users\yangg\AppData\Roaming\Python\Python36\site-packages\pip_vendor\distlib\scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip_vendor\distlib\scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip_vendor\distlib\scripts.py", line 212, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\clarkk\AppData\Roaming\Python\Python36\site-packages\pip_vendor\distlib\scripts.py", line 351, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

@pradyunsg

This comment has been minimized.

Show comment
Hide comment
@pradyunsg

pradyunsg May 7, 2018

Member

That'll be the same as #5343.

Member

pradyunsg commented May 7, 2018

That'll be the same as #5343.

@supermansaga

This comment has been minimized.

Show comment
Hide comment
@supermansaga

supermansaga May 7, 2018

Thanks pradyunsg, Someone else's solution turns out to be simpler. Just performed "python -m pip uninstall pip" first, then "python -m pip install -U pip"

Requirement already up-to-date: pip in c:\user\clarkk\appdata\local\Programs\Python\Python36\lib\site-packages (10.0.1)

Thanks pradyunsg, Someone else's solution turns out to be simpler. Just performed "python -m pip uninstall pip" first, then "python -m pip install -U pip"

Requirement already up-to-date: pip in c:\user\clarkk\appdata\local\Programs\Python\Python36\lib\site-packages (10.0.1)

bamarni added a commit to dcos/dcos-core-cli that referenced this issue Jul 11, 2018

Use `python -m pip install -U pip` on Windows
Don't run `pip install --upgrade pip` on Windows, it started to fail in
our Jenkins node and this is not the right command.

https://jira.mesosphere.com/browse/DCOS_OSS-2332
https://pip.pypa.io/en/stable/installing/#upgrading-pip
pypa/pip#1299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment