I install pip with:
$ sudo apt-get install python-setuptools, python-pip
But when I try install something with pip i have this error
sudo pip install Flask
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.3.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2565, in load_entry_point
raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'pip') not found
why?? Thanks.
sudo python3 -m pip install --upgrade --force-reinstall pip
may do the trick. Try it
I remove setuptools 0.9.4 and do 'pip install --upgrade setuptools' and work good.
you may check the /usr/bin/pip file, if it links to pip2, then change the first line of pip2 from '/usr/bin/python' to '/usr/bin/python2.7' or '/usr/bin/python2.x' matching pip2. If it links to pip3, then change to python3 or the version python3.x matching pip3.
It works for me because I have installed python 2.7 and 3 so and pip. So when I use 'pip' it using python3 as default, which resulting in the same output.
I was facing almost same error and having python2.7 installed on my mac.
I tried sudo python2.7 -m pip install --upgrade --force-reinstall pip and it worked for me.
If you have python3 installed then you can try sudo python3 -m pip install --upgrade --force-reinstall pip
Hope it will work.
I find there are multiple version pip on my Ubuntu,I followed these steps and it worked:
sudo apt-get remove python-pip
sudo rm -rf /usr/local/bin/pip-2.7 sudo rm -rf /usr/local/bin/pip
sudo rm -rf /usr/local/lib/python2.7/dist-packages/pip-1.4.1.egg-info
sudo easy_install -m pip-2.7 sudo easy_install -m pip
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python get-pip.py
Related
I am new to using Ubuntu and Linux in general. I just attempted to update Python by using sudo apt-get install python3.10. When I run python3.10 -m pip install <library name> I always receive the following error:
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/lib/python3/dist-packages/pip/__main__.py", line 19, in <module>
sys.exit(_main())
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 15, in <module>
from pip._internal.index.package_finder import PackageFinder
File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 21, in <module>
from pip._internal.index.collector import parse_links
File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 12, in <module>
from pip._vendor import html5lib, requests
ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py)```
I have tried doing sudo apt-get install python3.10-html5lib it downloaded something but it did not fix the error. How should I fix this error?
This is likely caused by a too old system pip version.
Install the latest with:
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
and test result
python3.10 -m pip --version
e.g.
pip 22.2.2 from <home>/.local/lib/python3.10/site-packages/pip (python 3.10)
and then test upgrade
python3.10 -m pip install --upgrade pip
e.g.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in <home>/.local/lib/python3.10/site-packages (22.2.2)
I have tried all the answers above but nothing worked for me. My python3 version is 3.10.2.
So I need to install the appropriate version for pip.
However, I have tried
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
But didn't work so, I tried
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
This worked for me
This is an expanded version of #mirekphd's comment which gave me a solution that worked both on my laptop and on our server perfectly without messing anything up.
First step, if not already done is to add the 'deadsnakes' repository so that the latest python related software can be downloaded and kept updated.
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
And, if you don't have Python 3.10 already installed you can do that with:
sudo apt install python3.10
And finally, to make pip work you will need to install the distutils package that's compatible with 3.10:
apt install python3.10-distutils
After that you can use pip the following way:
python3.10 -m pip _rest_of_the_pip
The above is necessary because the regular pip command will utilize the systems default python version and not 3.10.
If you use pip frequently then you can add an alias to your .bashrc file such as:
alias pip310='python3.10 -m pip'
After that you can just use it like this:
pip310 install blah
I've had this problem inside GitHub Actions. My solution was to resort to virtual environments to isolate from the rest of the system. Ensure python3.10-venv is installed and then do
python3.10 -m venv .venv
source .venv/bin/activate
pip install ...
...
deactivate
I had some issues installing pip as well
As sudo apt install python3-pip is still refering to pip3.8 (on mint Cinnamon 20.2 at least), pip needs to be installed in a other way.
With curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10, it turns out that pip is not found
ImportError: No module named 'pip._internal'
I found out that ensurepip command was built in and target the correct directory for python3.10
Running python3.10 -m ensurepip installs setuptools and pip and fix my missing pip module.
Pip can be updgraded afterwards using python3.10 -m pip install -U pip.
It also work with sudo (had some needs running pip as sudo)
At the time of writing and as stated on the following link. Python 3.10 is still unstable. Maybe it is a good idea to test what happens with python3.9 and see if the issue is in your local installation.
in any case, from a clean ubuntu (docker) installation by running (with sudo rights)
apt-get install software-properties-common
apt-get install python3.9
python3.9 --version
#
apt-get install python3.10
python3.10 --version
I got an the answers Python 3.9.5 and bash: python3.10: command not found respectively. so I guess the issue could be in the python 3.10 repository... for now.
However, apt-get install will not update directly your "default" python. You can check which are your those installations with
python --version
python3 --version
Any way, if you still want to install python3.10, perhaps the link above could help you.
Try:
pip3.10 install <package name>
Make sure you have the latest version pip and python3.10
The code for installing python and pip 3.10 for Ubuntu is all there, it's enough to swap just one line of that code, changing base image to the latest Ubuntu LTS version (that's ubuntu:focal) in the Dockerfile for the official Debian-based python 3.10 image (I used python 3.10 bullseye slim Dockerfile. Docker build took just 8 minutes, and here is proof that pip3.10 really works there:
$ docker run mirekphd/python3.10-ubuntu20.04 pip -V
Output:
pip 21.3.1 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
Or a more advanced example:
$ docker run -it --rm --name python3.10-ubuntu20.04 mirekphd/python3.10-ubuntu20.04:latest bash -c 'pip --version; pip install numpy --user --no-cache; pip show numpy; python -c "import numpy as np; print(np.ones(5))"'
Output:
pip 21.3.1 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
Collecting numpy
Downloading numpy-1.21.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.9 MB)
|████████████████████████████████| 15.9 MB 34.6 MB/s
Installing collected packages: numpy
WARNING: The scripts f2py, f2py3 and f2py3.10 are installed in '/root/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.21.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Name: numpy
Version: 1.21.4
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD
Location: /root/.local/lib/python3.10/site-packages
Requires:
Required-by:
[1. 1. 1. 1. 1.]
Note: to upgrade pip, I just added this line (before CMD):
RUN python -m pip install --upgrade pip
I've got the same error after installing python 3.10 on Ubuntu with python 3.8 on board.
uninstall pip and install it again
sudo apt-get remove -y python3-pip
sudo apt-get install -y python3-pip
it's worked for me, but pip3.10 install modulename got the same error, and python3.10 -m pip install modulename working fine.
in my case this problem is associated to a previous conda installation... so I solve it by correcting the PATH. Since also Python3.10 & pip3 are installed in ~/.local/bin
In the worst way, I added a last line to ~/.bashrc hardcoded as follows
nano ~/.bashrc
add the last line:
export PATH=/usr/local/sbin:/sbin:/usr/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/local/games:/usr/games:/home/$USER/.local/bin
save, close and run
source .bashrc
this was not enough, because after removing Conda's paths it still left pip installed in /usr/bin I solved this by renaming this pip
cd /usr/bin
sudo mv pip kkpip
sudo mv pip3 kkpip3
done
pip3 list
Voilà!
Install python 3.10, pip and venv in Ubuntu 18|20
sudo apt update && sudo apt upgrade -y
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.10
python3.10 --version
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
python3.10 -m pip --version
python3.10 -m pip install --upgrade pip
sudo apt install python3.10-venv
Create a virtual environment,
python3.10 -m venv venv3.10
source venv3.10/bin/activate
Need some help here.
I have two versions of pip and pip3 installed in different location.
When I try to do a pip install package-name it throws Error as:
ModuleNotFoundError: No module named 'pip._internal.cli'
pip 18.1 from /project/miniconda/lib/python3.7/site-packages/pip (python 3.7)
$ which pip
/project/miniconda/bin/pip
$ which pip3
/usr/local/bin/pip3
$ pip -V
pip 18.1 from /project/miniconda/lib/python3.7/site-packages/pip (python 3.7)
$ pip3 -V
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli'```
Since I don't have super user access, I cannot modify pip._internal.cli.main to pip.internal.cli.main.
Please help.
Please upgrade pip with python -m pip install --upgrade --force-reinstall pip.
You can try to install any package with: python -m pip install package-name for python2.7 and python3 -m pip install package-name for python3.
Using python -m pip install instead of just pip install is recommended. The reason is that it will use the correct interpreter for your python installation, specially if you have many versions installed. More details here: https://snarky.ca/why-you-should-use-python-m-pip/
Try this it worked for me
python3 -m pip install --user --upgrade pip
Image Link for code
Trying to install from pipenv with:
pipenv install mysqlclient
will reseult in:
Installing mysqlclient… Collecting mysqlclient Using cached
https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-5vhtqgve/mysqlclient/setup.py", line 17, in
metadata, options = get_config()
File "/tmp/pip-install-5vhtqgve/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-install-5vhtqgve/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Error: An error occurred while installing mysqlclient! Command
"python setup.py egg_info" failed with error code 1 in
/tmp/pip-install-5vhtqgve/mysqlclient/
This is likely caused by a bug in mysqlclient. Report this to its
maintainers.
I'm using a Debian and with another virtualenv it get the system package
python-mysqldb/testing,now 1.3.10-1 amd64
Pipenv won't use this one and won't install the other.
How can I solve this?
Thanks,BR
You probably need the mysql client lib for the OS.
sudo apt install libmysqlclient-dev
Then you should be able to:
pipenv install mysqlclient
I fixed that problem with the following command:
brew install mysql
First install python-dev
sudo apt-get install python3-dev
and then install mysqlclient-dev version
sudo apt-get install python3-dev libmysqlclient-dev
I would recommend you to install the file first.
On windows I used
pip install "mysqlclient-1.3.13-cp35-cp35m-win_amd64.whl"
and the tried:
pip install mysqlclient.
It worked well.
if you are on Centos
Try: yum install mariadb-devel
this package includes the missing mysql-config
Try:
sudo apt-get install libmysqlclient-dev
and then:
sudo apt-get install libmariadbclient-dev
I installed python3 and pip3 successfully on my Ubuntu16.04, but pip3 install is broken. How can I fix this problem? The error info of pip3 install is as follows:
# pip3 install xlwt
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.requests'
Output of "which pip3" and "pip3 --version":
# which pip3
/usr/bin/pip3
# pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.requests'
p.s. Python2 pip runs successfully.
Output of "which pip" and "pip --version":
# which pip
/usr/bin/pip
# pip --version
pip 1.5.4 from /usr/local/lib/python2.7/dist-packages/pip-1.5.4-py2.7.egg (python 2.7)
And python and python3 installation information:
# which python
/usr/bin/python
# which python3
/usr/bin/python3
# python -V
Python 2.7.14
# python3 -V
Python 3.6.3
Any solution or clue will be appreciated! Thank you!
Here, trying this method: https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
# sudo python3 get-pip.py
This has happened to me multiple times before. A lot of the time, pip3 has issues installing with python3 by default, so try uninstalling and reinstalling pip3. Hope this works.
sudo apt-get remove python3-pip; sudo apt-get install python3-pip
EDIT:
After doing some scouting about pip.vendor.requests, it seems like this is a very common error relating to SSL problems. If this line gives you errors in python (import ssl), some solutions can be found here:
https://github.com/pypa/pip/issues/2345.
This worked for me.
First remove your python3-pip:
sudo apt remove python3-pip
Then do this:
sudo apt install --purge python3-setuptools
And finally:
sudo apt install python3-pip
python-pip is in the universe repositories, therefore use the steps below to solve Python3 pip3 broken problem on Ubuntu. Also works for Ubuntu available from official store in windows 10 for WSL (windows subsystem for linux):
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get -y install python3-pip
I got help from here - [https://askubuntu.com/a/672836/876942]. Following these steps installs python 2. But then I installed python 3 using [sudo apt-get -y install python3-pip] in last step.
Whenever i try to use pip I get an error. For exampple:
$ sudo pip install gevent-websocket
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2675, in <module>
parse_requirements(__requires__), Environment()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 552, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.1
I feel tempted to change the value of into pip==0.8.2.. but I dont feel dealing with the consequences of 'hacking' up my installation...
I'm running python 2.7 and pip is at version 0.8.2.
I find this problem in my MacBook, the reason is because as #Stephan said, I use easy_install to install pip, and the mixture of both py package manage tools led to the pkg_resources.DistributionNotFound problem.
The resolve is:
easy_install --upgrade pip
Remember: just use one of the above tools to manage your Py packages.
I replaced 0.8.1 in 0.8.2 in /usr/local/bin/pip and everything worked again.
__requires__ = 'pip==0.8.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==0.8.2', 'console_scripts', 'pip')()
)
I installed pip through easy_install which probably caused me this headache.
I think this is how you should do it nowadays..
$ sudo apt-get install python-pip python-dev build-essential
$ sudo pip install --upgrade pip
$ sudo pip install --upgrade virtualenv
I had this issue when I was using homebrew. Here is the solution from Issue #26900
python -m pip install --upgrade --force pip
Try re-installing with the get-pip script:
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
This is sourced from the pip Github page, and worked for me.
If you're on CentOS make sure you have the YUM package "python-setuptools" installed
yum install python-setuptools
Fixed it for me.
The root of the problem are often outdated scripts in the bin (Linux) or Scripts (Windows) subdirectory. I'll explain this using problem I encountered myself as an example.
I had virtualenv version 1.10 installed in my user site-packages (the fact it's in user site-packages not sytem site-packages is irrelevant here)
pdobrogost#host:~$ which virtualenv
/home/users/pdobrogost/.local/bin/virtualenv
pdobrogost#host:~$ virtualenv --version
1.10
After I upgraded it to version 1.11 I got the following error:
pdobrogost#host:~$ virtualenv --version
Traceback (most recent call last):
File "/home/users/pdobrogost/.local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2701, in <module>
return self.__dep_map
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 572, in resolve
if insert:
pkg_resources.DistributionNotFound: virtualenv==1.10
File /home/users/pdobrogost/.local/bin/virtualenv mentioned in the error message looked like this:
#!/opt/python/2.7.5/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'virtualenv==1.10','console_scripts','virtualenv'
__requires__ = 'virtualenv==1.10'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('virtualenv==1.10', 'console_scripts', 'virtualenv')()
)
There, we see that virtualenv script was not updated and still requires previously installed version 1.10 of virtualenv.
Now, reinstalling virtualenv like this
pdobrogost#host:~$ pip install --user --upgrade virtualenv
Downloading/unpacking virtualenv from https://pypi.python.org/packages/py27/v/virtualenv/virtualenv-1.11.1-py27-none-any.whl#md5=265770b61de41d34d2e9fdfddcdf034c
Using download cache from /home/users/pdobrogost/.pip_download_cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fpy27%2Fv%2Fvirtualenv%2Fvirtualenv-1.11.1-py27-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
does not help (neither pip install --user --upgrade --force-reinstall virtualenv) because script /home/users/pdobrogost/.local/bin/virtualenv is left unchanged.
The only way I could fix this was by manually removing virtualenv* scripts from /home/users/pdobrogost/.local/bin/ folder and installing virtualenv again. After this, newly generated scripts refer to the proper version of the package:
pdobrogost#host:~$ virtualenv --version
1.11
I was able to resolve this like so:
$ brew update
$ brew doctor
$ brew uninstall python
$ brew install python --build-from-source # took ~5 mins
$ python --version # => Python 2.7.9
$ pip install --upgrade pip
I'm running w/ the following stuff (as of Jan 2, 2015):
OS X Yosemite
Version 10.10.1
$ brew -v
Homebrew 0.9.5
$ python --version
Python 2.7.9
$ ipython --version
2.2.0
$ pip --version
pip 6.0.3 from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.3-py2.7.egg (python 2.7)
$ which pip
/usr/local/bin/pip
I was facing the similar problem in OSx. My stacktrace was saying
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: setuptools>=11.3
Then I did the following
sudo pip install --upgrade setuptools
This solved the problem for me. Hope someone will find this useful.
On Mac OS X (MBP), the following (taken from another answer found herein) resolved my issues:
C02L257NDV33:~ jjohnson$ brew install pip
Error: No available formula for pip
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can:
sudo easy_install pip
C02L257NDV33:~ jjohnson$ sudo easy_install pip
Clearly the root cause here is having a secondary method by which to install python (in my case Homebrew). Hopefully, the people responsible for the pip script can remedy this issue since its still relevant 2 years after first being reported on Stack Overflow.
I had this problem because I installed python/pip with a weird ~/.pydistutils.cfg that I didn't remember writing. Deleted it, reinstalled (with pybrew), and everything was fine.
In my case (sam problem, but other packages) there was no version dependency. A sequence of pip uninstall and pip insstall did help.