I have built a simple PyGTK app using Python 3.5.2 and Msys but I need some modules not in the default installation, and although I could use setup.py install to get them I would much rather use pip.
I looked around and found this but it relates to Python 2 and gave an error when attempting to follow the instructions given:
$ python3 getpip.py
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
Collecting setuptools
Using cached setuptools-38.2.5-py2.py3-none-any.whl
Collecting wheel
Using cached wheel-0.30.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
Exception:
Traceback (most recent call last):
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\wheel.py", line 462, in move_wheel_files
generated.extend(maker.make(spec))
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\_vendor\distlib\scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\_vendor\distlib\scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\_vendor\distlib\scripts.py", line 212, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\Simon\AppData\Local\Temp\tmpoumuod3r\pip.zip\pip\_vendor\distlib\scripts.py", line 351, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
and I tried the way one would install pip on Linux:
pacman -S python2-pip
pacman -S python-pip
as listed here, as well as:
pacman -S python3-pip
but each time I got a error: target not found: error.
Surprisingly I couldn't find anything else.
So how do I get pip on Msys?
Thanks.
Please note that at this time the following command is now working on msys2:
$ pacman -S python3-pip
$ pip3 install --upgrade pip
The accepted answer installs a new Python exectuable with pip, but without GTK support.
In order to install pip support to the existing GTK Python executable, after encountering that error, we need to run:
python -m pip install -U --force-reinstall pip
(taken from this issue)
To summarize the steps required to install Pip support to the GTK-Python executable:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
(ignore the error from previous step)
python -m pip install -U --force-reinstall pip
To install pip, securely download get-pip.py.
Then run the following:
python get-pip.py
For more details refer: https://pip.pypa.io/en/stable/installing/
Related
I have a clean install of ubuntu 16.04 on an EC2 instance. I've gone ahead and upgraded the Python version from 3.5 to 3.7. Unfortunately, this seems to have rendered pip3 non-functional. Despite definitely having pip3 installed:
~$ which pip3
/usr/bin/pip3
when I try to do anything with pip3, it shows the same error:
~$ pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main' from 'pip' (/usr/local/lib/python3.7/site-packages/pip/__init__.py)
I have tried upgrading pip via
sudo python3 -m pip install --upgrade pip
and getting pip from source via
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
Neither has fixed the problem. Any ideas on what might be going on? I've managed to get replicate the error by undertaking the upgrade to 3.7 on a clean EC2 server, though I also was hitting the same thing on another EC2 instance when upgrading to 3.7. I'm guessing this has to do with ubuntu in that case--is there a reason that 3.7 isn't playing nicely with my pip?
Edit:
Suggested re-installing pip via
python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
That yields the following error trace:
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 188, in main
status = self.run(options, args)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/uninstall.py", line 48, in run
with self._build_session(options) as session:
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 108, in _build_session
index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.7/site-packages/pip/_internal/download.py", line 559, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.7/site-packages/pip/_internal/download.py", line 144, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 122, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 677, in linux_distribution
self.version(),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 737, in version
self.lsb_release_attr('release'),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 899, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 552, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 1012, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
**kwargs).stdout
File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
It's possible that the system pip has been corrupted, maybe try un-installing/re-installing pip via python3:
python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
Pip developers say very clearly:
Only ever use your system package manager to upgrade the system pip
pip3 can be configured for old python. Use pythonx.x -m pip instead so you're sure that you're installing packages for the right python version.
I suggest installing pip the official way . Deb pip packages will have very old pip, and it's hard to update them without breaking anything. If you installed something like python3.7-pip I suggest removing it.
PS: I hope that by upgrading python you mean installing 3.7 besides system 3.5, because replacing python3.5 will likely break something in your OS.
What is the problem? I tried "python -m pip install -U pip" and "python -m pip install --upgrade pip" both with the same error (and "pip install -U --force-reinstall pip"). what should I do?
C:\Users\Peyman\PycharmProjects\untitled3>python -m pip install -U pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-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\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\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\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\wheel.py", line 462, in move_wheel_files
generated.extend(maker.make(spec))
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 212, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\Peyman\AppData\Roaming\Python\Python35\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 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Try using easy_install -U pip, according to this bug report.
Edit: Okay, go to "https://pypi.org/simple/pip/", and download the latest .whl file (scroll to the bottom). When you have it, open cmd in the same folder (by clicking File -> open powershell/cmd in the file explorer), and type
pip install filename, with filename being the name of the file you downloaded (Should be pip-18.0-py2.py3-none-any.whl).
Try that and tell me if it works.
You can try this following:
python -m pip install -U --force-reinstall pip
My answer is a variation of assmmahmud's but for me I had to use the option --user.
I'm on windows so from CMD.exe;
py -m pip install --user --force-reinstall -U
If I don't use the --user option then the error occurs.
Download get-pip.py from the official site and run this code:
$ python get-pip.py
or on Windows, this one:
py get-pip.py
Basically, the title. I want to upgrade pip because I cannot get new packages in python because it is obsolete.
When I try to run pip3 install --upgrade pip from the Ubuntu terminal, this happens:
Collecting pip
Using cached pip-9.0.3-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "/home/marcell/.local/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/marcell/.local/lib/python3.5/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/home/marcell/.local/lib/python3.5/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/home/marcell/.local/lib/python3.5/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/home/marcell/.local/lib/python3.5/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/home/marcell/.local/lib/python3.5/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/marcell/.local/lib/python3.5/site-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/home/marcell/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/pip'
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
How should I solve this problem? I tried to purge pip and reinstall it,but to no avail.
Edit: Also, tried the upgrade command with pip too, but it didn't seem to work.
I have two solutions to your problem
Try using sudo as stated in above answer.
sudo pip3 install --upgrade pip
Try to do fresh reinstall of pip
apt-get remove python3-pip
pip3 install -U pip
NOTE: This can be done for python2x ,by replace pip3 by pip2
Try:
sudo pip3 install --upgrade pip
"Permission denied" errors are usually solved by adding "sudo" to your commands.
(sudo is just a keyword to execute a given command with privileges)
If you get a "command not found" then you should do the following:
Type Python into your command console, it will tell you which version of Python you are using.
C:/>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
If you have Python 3.x you should use pip3, if you have Python 2.x you should use pip.
If you are using the right pip but still get the "command not found" then you have to install pip:
For Python2.x:
sudo apt-get install python-pip
For Python 3.x:
sudo apt-get install python3-pip
Okay, so, I run my project packages in a virtual environment. I usually manage these packages through PyCharm. PyCharm tells me I have Pip 9.0.1 installed. Only when I run my virtual environment from the command line and I print pip version, it says 7.1.0. If I try upgrading using pip install --upgrade pip I get an error
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 7.1.0
Uninstalling pip-7.1.0:
Successfully uninstalled pip-7.1.0
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\basecommand.py", line 223, in main
status = self.run(options, args)
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\commands\install.py", line 299, in run
root=options.root_path,
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_set.py", line 646, in install
**kwargs
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_install.py", line 813, in install
self.move_wheel_files(self.source_dir, root=root)
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_install.py", line 1008, in move_wheel_files
isolated=self.isolated,
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\wheel.py", line 449, in move_wheel_files
generated.extend(maker.make(spec))
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\_vendor\distlib\scripts.py", line 323, in make
self._make_script(entry, filenames, options=options)
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\_vendor\distlib\scripts.py", line 227, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\_vendor\distlib\scripts.py", line 163, in _write_script
launcher = self._get_launcher('t')
File "c:\python-virtualenv\arcus\lib\site-packages\pip-7.1.0-py3.5.egg\pip\_vendor\distlib\scripts.py", line 302, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
My system-wide pip version is 9.0.1 though. I just don't get what is happening. Hopefully someone can shed some light. I've tried de-installing and re-installing it again, I've tried using a wheel to install, doesn't work
Windows, by the way.
I had the same issue, but found the answer here:
https://github.com/pypa/pip/issues/2669
Basicly I just had to use this command instead:
easy_install -U pip
Open the Command Prompt (cmd) as administrator and run:
pip install --user --upgrade pip
Or try:
python -m pip install --user --upgrade pip
Relevant GitHub issue.
I'm running Python on a slightly older OS, whose system Python is at version 2.6. Hence I have 2.7 installed in my home directory and used that Python to get pip, and used that pip to install virtualenvwrapper. So I have
$ which python pip virtualenv virtualenvwrapper.sh
/home/user/bin/python
/home/user/bin/pip
/home/user/.local/bin/virtualenv
/home/user/.local/bin/virtualenvwrapper.sh
I use these tools to create a virtualenv, and try to install a module
$ mkvirtualenv fred
New python executable in fred/bin/python2.7.10
Also creating executable in fred/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/preactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/postactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/get_env_details
$ workon fred
$ export PYTHONPATH=/home/user/.virtualenvs/fred/lib/python2.7/site-packages
$ /home/user/.virtualenvs/fred/bin/easy_install --prefix=/home/user/.virtualenvs/fred pip
Creating /home/user/.virtualenvs/fred/lib/python2.7/site-packages/site.py
Searching for pip
Best match: pip 7.1.2
Adding pip 7.1.2 to easy-install.pth file
Installing pip script to /home/user/.virtualenvs/fred/bin
Installing pip3.4 script to /home/user/.virtualenvs/fred/bin
Installing pip3 script to /home/user/.virtualenvs/fred/bin
Using /home/user/.virtualenvs/fred/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
$ which python pip
/home/user/.virtualenvs/fred/bin/python
/home/user/.virtualenvs/fred/bin/pip
$ pip install itsdangerous
Collecting itsdangerous
Installing collected packages: itsdangerous
Exception:
Traceback (most recent call last):
File "/home/user/.local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/home/user/.local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/home/user/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
**kwargs
File "/home/user/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File "/home/user/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/home/user/.local/lib/python2.7/site-packages/pip/wheel.py", line 341, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/user/.local/lib/python2.7/site-packages/pip/wheel.py", line 319, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/lib64/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/itsdangerous.py'
Why is pip trying to install the module into /usr/lib? Shouldn't it be installed to ~/.virtualenvs/fred/lib, or ~/lib?
Status as of Jul 4th, 2018:
Unreproducible, as I do not have access to that company's servers any more, and I have not seen it on other systems since.
Probably your are calling the system level pip and not the virtualenv pip.
You should activate your virtualenv before:
. bin/activate