I want to install pillow, but when I run pip install pillow in the cmd I get the following message:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pillow
Downloading https://files.pythonhosted.org/packages/5e/b6/8960697526a79bd1cb4520293078be3a10d725f23f20abbee298ebdeaabd/Pillow-6.2.2-cp27-cp27m-win_amd64.whl (1.9MB)
|ERROR: Could not install packages due to an EnvironmentError: [Errno 42] Illegal byte sequence
WARNING: You are using pip version 19.2.3, however version 20.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Python 3.8.2 is already installed on my computer and I added it to PATH.
I also ran python -m pip install --upgrade pip and nothing has changed.
What is the problem? Do I need to update the Python version?
Installation using third party PPA repository
Step 1: First install the Ubuntu software properties package if it’s not already installed on your system.
$ sudo apt update
$ sudo apt install software-properties-common
Step 2: After that run the commands to add the PPA.
$ sudo add-apt-repository ppa:deadsnakes/ppa
Step 3: Finally, run below to install Python 3.8
$ sudo apt update
$ sudo apt install python3.8
You can check as below:
$ python3 --version
Python 3.8.1
OK done.
Don't use the pip, pip3, etc. scripts ever. Instead always prefer the more explicit and surefire way of calling pip's executable module for a specific instance of the Python interpreter, for example:
path/to/pythonX.Y -m pip install Pillow
References:
https://snarky.ca/why-you-should-use-python-m-pip/
https://snarky.ca/a-quick-and-dirty-guide-on-how-to-install-packages-for-python/
Check if Python3 is correctly installed by, for example, running python3 -V in the command-line (this will show you the installed version)
This should show something like Python 3.8 ...
If you get an error here, like it is an unknown command, something probably went wrong during the installation...
Run pip3 install pillow to install pillow (Python 3)
Kindly download it at Python official website.
There is an option to update your version during the installation which is very useful.
I'm having problems while installing a new package in Python. I was looking for the termcolor package. I installed it using the apt:
sudo apt-get install python-termcolor
But when I try to use it in Python 3.6 it keep telling me that's not installed. I checked whether it was and I got:
cris#Manaos:~$ dpkg -L python-termcolor
/.
/usr
/usr/share
/usr/share/pyshared
/usr/share/pyshared/termcolor-1.1.0.egg-info
/usr/share/pyshared/termcolor.py
/usr/share/doc
/usr/share/doc/python-termcolor
/usr/share/doc/python-termcolor/README.rst
/usr/share/doc/python-termcolor/copyright
/usr/share/doc/python-termcolor/changelog.Debian.gz
/usr/share/doc/python-termcolor/CHANGES.rst
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/termcolor-1.1.0.egg-info
/usr/lib/python2.7/dist-packages/termcolor.py
So I understand that the package was correctly installed, but in the v2.7. How do I get it installed in the v3.6?
EDIT: I've read that if a use the pip installer, I could assign in which version of Python I'd like it installed, like using pip3 to install the package in 3.XX. But I tried it, it says that it was correctly installed and when I open Python 3.6 and try to use it, still got the ModuleNotFoundError.
EDIT2: After checking one more time, I discovered that with pip3 I installed the termcolor package in Python 3.5.3, but how can I get it installed in Python 3.6.1?
You need to specify you want the python 3 version.
sudo apt-get install python3-termcolor
I'm using Mac OS X 10.10. I want to use pip to install packages for my homebrew installed version of python (located in /usr/local/bin/python, which is an alias that points to /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin). It appears that site-packages for this version are here: /usr/local/lib/python2.7/site-packages/.
which python returns /usr/local/bin/python
which pip returns /usr/local/bin/pip
These seem correct to me.
Trying something like pip install pylzma returns:
Collecting pylzma
Installing collected packages: pylzma
Successfully installed pylzma
You are using pip version 8.0.2, however version 8.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
But then pip list does not show pylzma to be installed. It looks like pip installs the packages to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (the python that ships with Mac OS X).
How can I get pip to install to my homebrewed python?
I've tried a number of suggestions from similar questions:
I've tried export PATH=/usr/local/bin/python:${PATH}.
I've tried pip install --install-option="--prefix=/usr/local/lib/python2.7" pylzma.
I've tried changing the first line of the pip executable script to #!/usr/local/bin/python
I've tried /usr/local/bin/python -m pip install pylzma.
But none of these work. I also tried upgrading pip to 8.1.1, but that made pip break entirely. People recommend using virtualenv, but as far as I know, I can't install that without pip.
When I type python -m pip, it says:
Usage:
/usr/local/opt/python/bin/python2.7 -m pip <command> [options]
Could that be a problem?
My issue was that my /Users/<username>/.pydistutils.cfg contained the following:
[easy_install]
# set the default location to install packages
install_dir = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
[install]
install_lib = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
install_scripts = ~/bin
I changed this to:
[easy_install]
# set the default location to install packages
install_dir = /usr/local/lib/python2.7/site-packages
[install]
install_lib = /usr/local/lib/python2.7/site-packages
install_scripts = ~/bin
That seemed to have worked. pip install now installs packages to the desired location /usr/local/lib/python2.7/site-packages.
However, I am have ongoing path issues.
import pylzma still gives me ImportError: No module named pylzma.
and running jupyter notebook in terminal gives -bash: jupyter: command not found. /Users/<username>/bin/jupyter notebook does execute, but I get ImportError: No module named markupsafe despite the fact that /usr/local/lib/python2.7/site-packages/MarkupSafe-0.23.dist-info exists.
EDIT: I got jupyter notebook working eventually. I had to install several packages from the source tarballs directly, including MarkupSafe, functools32, and jsonschema. Maybe Python is not looking in the correct folder or something.
I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have the error when installing numpy in the virtualenv.
Maybe, you have any ideas to fix?
The problem is SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
so do the following in order to obtain 'Python.h'
make sure apt-get and gcc are up to date
sudo apt-get update
sudo apt-get upgrade gcc
then install the python2.7-dev
sudo apt-get install python2.7-dev
and I see that you have most probably already done the above things.
pip will eventually spit out another error for not being able to write into /user/bin/blahBlah/dist-packages/ or something like that because it couldn't figure out that it was supposed to install your desiredPackage (e.g. numpy) within the active env (the env created by virtualenv which you might have even changed directory to while doing all this)
so do this:
pip -E /some/path/env install desiredPackage
that should get the job done... hopefully :)
---Edit---
From PIP Version 1.1 onward, the command pip -E doesn't work. The following is an excerpt from the release notes of version 1.1 (https://pip.pypa.io/en/latest/news.html)
Removed -E/--environment option and PIP_RESPECT_VIRTUALENV; both use a restart-in-venv mechanism that's broken, and neither one is useful since every virtualenv now has pip inside it. Replace pip -E path/to/venv install Foo with virtualenv path/to/venv && path/to/venv/pip install Foo
If you're on Python3 you'll need to do sudo apt-get install python3-dev. Took me a little while to figure it out.
If you're hitting this issue even though you've installed all OS dependencies (python-devel, fortran compiler, etc), the issue might be instead related to the following bug:
"numpy installation thru install_requires directive issue..."
Work around is to manually install numpy in your (virtual) environment before running setup.py to install whatever you want to install that depends on numpy.
eg, pip install numpy then python ./setup.py install
This answer is for those of us that compiled python from source or installed it to a non standard directory. In my case, python2.7 was installed to /usr/local and the include files were installed to /usr/local/include/python2.7
C_INCLUDE_PATH=/usr/local/include/python2.7:$C_INCLUDE_PATH pip install numpy
I recently had the same problem. I run Debian Jessie and tried to install numpy from a Python 2.7.9 virtualenv. I got the same error -- numpy complaining that Python.h is missing while python2.7-dev and gcc are already installed.
File "numpy/core/setup.py", line 42, in check_types
],
File "numpy/core/setup.py", line 293, in check_types
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
I'm running pip 1.5.6 and it doesn't appear to have command line option '-E'
$ pip -V
pip 1.5.6 from /home/alex/.virtualenvs/myenv/local/lib/python2.7/site- packages (python 2.7)
Upgrading pip to the latest verson 7.0.3 solves the problem
$ pip install --upgrade pip
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.0.3-py2.py3-none-any.whl#md5=6950e1d775fea7ea50af690f72589dbd
Downloading pip-7.0.3-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Installing collected packages: pip
Found existing installation: pip 1.5.6
Uninstalling pip:
Successfully uninstalled pip
Successfully installed pip
Cleaning up...
Now it is possible to install numpy
$ pip install numpy
Collecting numpy
Downloading numpy-1.9.2.tar.gz (4.0MB)
100% |████████████████████████████████| 4.0MB 61kB/s
Installing collected packages: numpy
Running setup.py install for numpy
Successfully installed numpy-1.9.2
This is probably because you do not have the python-dev package installed. You can install it like this:
sudo apt-get install python-dev
You can also install it via the Software Center:
#samkhan13 solution didn't work for me as pip said it doesn't have the -E option.
I was still getting the same error, but what worked for me was to install matplotlib, which installed numpy.
I'm having troubles with installing packages in Python 3.
I have always installed packages with setup.py install. But now, when I try to install the ansicolors package I get:
importerror "No Module named Setuptools"
I have no idea what to do because I didn't have setuptools installed in the past. Still, I was able to install many packages with setup.py install without setuptools. Why should I get setuptools now?
I can't even install setuptools because I have Python 3.3 and setuptools doesn't support Python 3.
Why doesn't my install command work anymore?
Your setup.py file needs setuptools. Some Python packages used to use distutils for distribution, but most now use setuptools, a more complete package. Here is a question about the differences between them.
To install setuptools on Debian:
sudo apt-get install python3-setuptools
For an older version of Python (Python 2.x):
sudo apt-get install python-setuptools
EDIT: Official setuptools dox page:
If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from
python.org, you will already have pip and setuptools, but will need to
upgrade to the latest version:
On Linux or OS X:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
Therefore the rest of this post related to Distribute is obsolete (e.g. some links don't work).
EDIT 2022-02-04
From Python 3.10 Distutils is deprecated and will be removed in Python 3.12 - use setuptools:
The entire distutils package is deprecated, to be removed in Python 3.12. Its functionality
for specifying package builds has already been completely replaced by
third-party packages setuptools and packaging ...
Distribute (deprecated)
Distribute - is a setuptools fork which "offers Python 3 support". Installation instructions for distribute(setuptools) + pip:
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
Similar issue here.
UPDATE: Distribute seems to be obsolete, i.e. merged into Setuptools: Distribute is a deprecated fork of the Setuptools project. Since the Setuptools 0.7 release, Setuptools and Distribute have merged and Distribute is no longer being maintained. All ongoing effort should reference the Setuptools project and the Setuptools documentation.
You may try with instructions found on setuptools pypi page (I haven't tested this, sorry :( ):
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
easy_install pip
Make sure you are running the latest version of pip
I tried to install Ansible and it failed with
ModuleNotFoundError: No module named 'setuptools_rust'
python3-setuptools was already in place, so upgrading pip solved it.
pip3 install -U pip
I was doing this inside a virtualenv on Oracle Linux 6.4 using Python 2.6, so the apt-based solutions weren't an option for me, nor were the Python 2.7 ideas. My fix was to upgrade my version of setuptools that had been installed by virtualenv:
pip install --upgrade setuptools
After that, I was able to install packages into the virtualenv.
The solution which worked for me was to upgrade my setuptools:
python3 -m pip install --upgrade pip setuptools wheel
For others with the same issue due to a different reason: This can also happen when there's a pyproject.toml in the same directory as the setup.py, even when setuptools is available.
Removing pyproject.toml fixed the issue for me.
pip uninstall setuptools
and then:
pip install setuptools
This works for me and fixes my issue.
When there's a pyproject.toml in the same directory as the setup.py, it can be the cause of the issue. I renamed that file, but it didn't solve the issue, so I restablished the original file name, and did the following change.
Under the [build-system] section, I added "setuptools" to the requires= list, and it worked.
First step #1
You have to install setuptools
On Linux:
pip install -U pip setuptools
On Mac OS:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
Second step #2
Make sure you have made it accessible (make it available in environmental variables)
On Linux
export PATH="INSTALLATIONDIRECTORY:$PATH"
On Mac OS
Sorry, I don't know.
On Windows
Open the Start Search, type in “env”, and choose “Edit the system environment variables”
Click the “Environment Variable” button.
Set the environment variables as needed. The New button adds an additional variable.
Dismiss all of the dialogs by choosing “OK”. Your changes are saved!
The distribute package provides a Python 3-compatible version of setuptools: http://pypi.python.org/pypi/distribute
Also, use pip to install the modules. It automatically finds dependencies and installs them for you.
It works just fine for me with your package:
[~] pip --version
pip 1.2.1 from /usr/lib/python3.3/site-packages (python 3.3)
[~] sudo pip install ansicolors
Downloading/unpacking ansicolors
Downloading ansicolors-1.0.2.tar.gz
Running setup.py egg_info for package ansicolors
Installing collected packages: ansicolors
Running setup.py install for ansicolors
Successfully installed ansicolors
Cleaning up...
[~]
this is how my problem was solved => pip3 install setuptools-rust
If you want to check your list => pip3 list
i faced this problem while trying to install elastalert2
System informations
CentOS Linux release 7.9.2009 (Core)
Python 3.6.8
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
I ran into this problem when my pip requirements.txt file contained an editable library that was built using poetry and contained a pyproject.toml file. Following the documentation for setuptools, my solution was to add setuptools to the build-system requirements in the pyproject.toml file as follows:
[build-system]
requires = ["poetry-core>=1.0.0", "setuptools"]
build-backend = "poetry.core.masonry.api"
If pip isn't installed, like for example if it's coming from the Deadsnakes PPA, or a Docker environment, the best way to fix this error is by bootstrapping it by running
python -m ensurepip
Windows 7:
I have given a complete solution here for Python Selenium WebDriver:
Setup easy install (Windows - simplified)
download ez.setup.py (https://bootstrap.pypa.io/ez_setup.py) from 'https://pypi.python.org/pypi/setuptools'
move ez.setup.py to C:\Python27\
open cmd prompt
cd C:\Python27\
C:\Python27\python.exe ez.setup.py install
I ran sudo python setup.py build_ext -i and it failed with No module named setuptools.
I solved it with this command:
<i>sudo apt-get install python-setuptools</i>
A few years ago I inherited a Python (2.7.1) project running under Django-1.2.3 and now was asked to enhance it with QR possibilities. I got the same problem and did not find pip or apt-get either. So I solved it in a totally different, but easy way.
I /bin/vi-ed the setup.py and changed the line
"from setuptools import setup"
into:
"from distutils.core import setup"
The PyPA recommended tool for installing and managing Python packages is pip. pip is included with Python 3.4 (PEP 453), but for older versions here's how to install it (on Windows):
Download https://bootstrap.pypa.io/get-pip.py
>c:\Python33\python.exe get-pip.py
Downloading/unpacking pip
Downloading/unpacking setuptools
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...
>c:\Python33\Scripts\pip.exe install pymysql
Downloading/unpacking pymysql
Installing collected packages: pymysql
Successfully installed pymysql
Cleaning up...
On macOS, if you have homebrew installed, simply run:
brew install rust
If you still find this issue, try this:
python3 -m pip install scrapy --upgrade --force --user
While trying to install socketIO I had the same issue. At my system (Windows 11) setupTools were there twice. At C:\Program Files\Python310\Lib\site-packages\ and at C:\Users\user\AppData\Roaming\Python\Python310\site-packages\
Had to uninstall one of them.
Working on Debian, sometime it can be because of older pip version. Therefore, update pip>
python -m pip install -U pip
I had such a problem to install pyunicorn. I wanted to install it on Google Colab. I tried installing pyunicorn directly from Github and it worked for me. For example in my case it was like this:
pip install git+https://github.com/pik-copan/pyunicorn.git#egg=pyunicorn