pip install PIL fails - python

I am trying to install the pip package PIL. However the install doesn't work throwing the following error.
Could not find a version that satisfies the requirement pil (from xhtml2pdf==0.0.4->-r virtualenv-reqs.txt (line 16)) (from versions: )
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external pil to allow).
No matching distribution found for pil (from xhtml2pdf==0.0.4->-r virtualenv-reqs.txt (line 16))
The install does work when I have an older version of pip, but with the current version of pip 7.1.2 I am not able to download the package. I am using the following command to install the pip packages
pip install --timeout=1000 -i http://pypi.ksjc.sh.colo/simple --trusted-host pypi.ksjc.sh.colo -r virtualenv-reqs.txt
What is the issue with this. I thought it might be an SSL issue which is why I added the --trusted-host flag. Is there any way to the --allow-external flag to be used with the virtualenv-reqs file.

Pillow is a maintained fork of PIL, so I recommend using Pillow. But you can't have both installed at the same time.
First, remove both PIL and Pillow.
Then install Pillow with pip install pillow (although, depending on platform, you may need some prerequisites).
Then make sure code is using from PIL import Image rather than import Image.

You can try using Pillow instead, which is a PIL fork:
pip install Pillow
To import use following:
from PIL import Image

One solution that worked for me:
By simply installing the latest version of Pillow using pip install -U Pillow I can now call import PIL.Image

I'm using PyCharm IDE, and I had this problem. I simply hovered my mouse to the 'PIL' and there's a small pop-up. I clicked more actions and several options appear. I clicked 'Install Pillow, and then, problem solved.

One solution was, right-click on 'from PIL import Image' and click
'install Image'
I was on the PyCharm IDE.

Related

Meeting a pip requirement using an alternative module

I'm trying to install a python module, 'pyAudioProcessing' (https://github.com/jsingh811/pyAudioProcessing) on my Linux Mint distribution, and one of the items in requirements.txt is causing issues: python-magic-bin==0.4.14. When I run pip3 install -e pyAudioInstaller, I get an error:
ERROR: Could not find a version that satisfies the requirement python-magic-bin==0.4.14 (from pyAudioProcessing==1.1.5) (from versions: none)
ERROR: No matching distribution found for python-magic-bin==0.4.14 (from pyAudioProcessing==1.1.5)
The same error appears if I try to manually install the module using pip3 install python-magic-bin. The module installs without issues on my windows machine.
pypi.org lets me download files for it manually, however only Windows and MacOS .whl files are available. I tried simply removing the requirement from the list, but that resulted in a large number of other errors to appear, so I assume the module is legitimately required.
Thee is another module called python-magic-debian-bin that I can download. Is there a simple way to convince pyAudioInstaller to use this other module instead of the original? Like can I somehow rename python-magic-debian-bin to python-magic-bin and hope it works out?
python-magic-bin 0.4.14 provides wheels for OSX, w32 and w64, but not for Linux. And there is no source code at PyPI.
You need to install it from github:
pip install git+https://github.com/julian-r/python-magic.git
As for pyAudioProcessing I can see 2 ways to install it:
Clone the repository and edit requirements/requirements.txt, replace python-magic-bin==0.4.14 with pip install git+https://github.com/julian-r/python-magic.git#egg=python-magic;
Install requirements manually and then install pyAudioProcessing without dependencies:
pip install --no-deps pyAudioProcessing
or
pip install --no-deps git+https://github.com/jsingh811/pyAudioProcessing.git
The library has updated the requirements very recently for it to work on Linux.
pip install -U pyAudioProcessing
Should get it all set up for you.
Alternatively, https://github.com/jsingh811/pyAudioProcessing the readme describes other getting started methods as well.

Attempting to install Python PIL module fails with "Non-zero exit code"

I really don't get why Python is so difficult to get up and running properly.
Anyway, I've just fresh installed Python 3.7 and PyCharm. I want to get the Python Imaging Library working within my project, but when I try to install it using PyCharm I get the following error:
pip install PIL
Non-zero exit code (1)
Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\Users\Jake\AppData\Local\Programs\Python\Python37-32\python.exe'.
Command output:
Collecting PIL
Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I've attempted to run python -m pip install --upgrade pip from a CMD prompt, but I then get this error:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
I just tried to install NumPy using the exact same method for PIL and Numpy installed without any issues whatsoever. This leads me to think that maybe PIL isn't supported for Python 3.7?
Can someone explain to me what the issue is here and help me with importing modules into my PyCharm project?
PIL is not maintained anymore. You can use Pillow instead, a more active fork of PIL.
pip install Pillow

Cannot import cv2 on PyCharm

I am trying to import cv2 module in PyCharm, but it shows error.
I tried in terminal as well
pip install opencv-python
pip3 install cv2
pip install opencv-python
pip3 install cv2
and whatnot.
Trying to install opencv-python from terminal shows this
Requirement already satisfied: opencv-python in ./anaconda3/lib/python3.6/site-packages (3.4.1.15)
and trying to install cv2 from terminal shows this
Could not find a version that satisfies the requirement cv2 (from versions: )
No matching distribution found for cv2
However, trying to import cv2 on Pycharm shows this :
Pycharm Error Image
First, install the package named opencv-python via pip install opencv-python or use the GUI.
Second, just input import cv2; that is ok.
Go to File->Settings->Project Interpreter and then add by '+' button 'opencv-python' module on this repository.
It downloaded without an error for my PyCharm and also downloaded the dependencies as well.
While creating a new project in PyCharm, please select 'Base Interpreter' option from drop-down similar to the one shown in this link:
Creating new Project stage
Next, after successful creation of project and after downloading the opencv-python, it looks a shown in this link:
Success message

Install PIL/Pillow for ubuntu python 2.7

I have successfully installed PIL/Pillow for python 3.4 but I want it for python 2.7. I thought it might be automatically downloaded for 2.7 as well but when I tried the python shell from the terminal, it keeps saying No module named PIL and No module named PILLOW. What can I do? When I try all the installation commands as given in other answers, it says:
Requirement already satisfied (use --upgrade to upgrade): pillow in ./.local/lib/python3.4/site-packages
My problem is the opposite of this
Install PIL using pip install pillow
Then in the shell try import PIL or from PIL import ...
In python 2.7 there is no module named PIL,
you can use PIL features through Pillow,so PIL aka Pillow
Your output shows you are still using python3
Switch to python 2.7 and try pip install pillow
Then you can directly import PIL and use its methods completely

Trouble installing pygame using pip install

I tried: c:/python34/scripts/pip install http://bitbucket.org/pygame/pygame
and got this error:
Cannot unpack file C:\Users\Marius\AppData\Local\Temp\pip-b60d5tho-unpack\pygame
(downloaded from C:\Users\Marius\AppData\Local\Temp\pip-rqmpq4tz-build, conte
nt-type: text/html; charset=utf-8); cannot detect archive format
Cannot determine archive format of C:\Users\Marius\AppData\Local\Temp\pip-rqmp
q4tz-build
Please if anyone have any solutions please feel free to share them!
I also tried
pip install --allow-unverified, but that gave me an error as well.
This is the only method that works for me.
pip install pygame==1.9.1release --allow-external pygame --allow-unverified pygame
--
These are the steps that lead me to this command (I put them so people finds it easily):
$ pip install pygame
Collecting pygame
Could not find any downloads that satisfy the requirement pygame
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external pygame to allow).
No distributions at all found for pygame
Then, as suggestes I allow external:
$ pip install pygame --allow-external pygame
Collecting pygame
Could not find any downloads that satisfy the requirement pygame
Some insecure and unverifiable files were ignored (use --allow-unverified pygame to allow).
No distributions at all found for pygame
So I also allow unverifiable:
$ pip install pygame --allow-external pygame --allow-unverified pygame
Collecting pygame
pygame is potentially insecure and unverifiable.
HTTP error 400 while getting http://www.pygame.org/../../ftp/pygame-1.6.2.tar.bz2 (from http://www.pygame.org/download.shtml)
Could not install requirement pygame because of error 400 Client Error: Bad Request
Could not install requirement pygame because of HTTP error 400 Client Error: Bad Request for URL http://www.pygame.org/../../ftp/pygame-1.6.2.tar.bz2 (from http://www.pygame.org/download.shtml)
So, after a visit to http://www.pygame.org/download.shtml, I thought about adding the version number (1.9.1release is the currently stable one).
--
Hope it helps.
If you get trouble when install pygame error about missing visual studio 10+. I have the answer:
The problem is not about have or not have visual studio, because I try many version but it not work. The problem is file: between tar.gz and .whl
so, this is the solution:
1) Download file:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Go here and download your pygame version, notice about x64 or x86 and python version. My system is x64 and python is 3.4 so I choose: pygame-1.9.2a0-cp34-none-win_amd64.whl
2) Put it in some where to install:
I put it in "C:", so open cmd: and type:
cd C:\ (this is change location to C:)
3) Install
pip install C:\pygame-1.9.2a0-cp34-none-win_amd64.whl
Done !
I realized that the compatible Pygame version was simply corrupted or broken. Therfore i had to install a previous version of python to run Pygame. Which is actually fine as most modules aren't updated to be compatible with Python 3.4 yet so it only gives me more options.
I myself got this error(while using v3.10.0) and then I uninstalled the latest version and installed older version of python(v3.9.7) and it fixed the issue. Hope that works for you too. Honestly there are not many changes in the fix unless they jump from python3 to python4. so you dont need to update the python just for the sake of latest-ality

Categories

Resources