I installed the pillow 3.3.0 package for Python 3.5.2 Mac by using the pip3 install statement in terminal, it successfully downloaded and installed. (I did the same for other pacakges.)
When trying to call import pillow, following warning is displayed:
>>>import pillow
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from pillow import *
ImportError: No module named 'pillow'
I took following steps:
Those are the packages locally installed:
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
['numpy==1.11.1', 'pillow==3.3.0', 'pip==8.1.2', 'psycopg2==2.6.2', 'setuptools==20.10.1']
When pip3 installing pillow again, following warning shows up:
MyComputer-MBP-2:~ user$ pip3 install Pillow
Requirement already satisfied (use --upgrade to upgrade): Pillow in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Other packages work just fine.
The importable name of the Pillow library is PIL because it is a fork of the original PIL. Just do
from PIL import *
Or even better, only import those names you actually need—see this SO thread.
the package name is PIL
use
from PIL import *
Related
I am trying to use PIL in my project. I sourced my venv and then installed using pip3 install Pillow. I verified that the module is in fact installed but yet I am still getting the error.
pip3 list
Package Version
---------- -------
asgiref 3.5.2
Django 4.1.1
Pillow 9.2.0
pip 22.2.2
setuptools 63.4.3
six 1.16.0
sqlparse 0.4.3
(env) mike#Mikes-MacBook-Air test_app % /Users/mike/.pyenv/versions/3.9.2/bin/python /Users/mike/Desktop/bank_app/main.py
Traceback (most recent call last):
File "/Users/mike/Desktop/bank_app/main.py", line 3, in <module>
from PIL import Image, ImageTk
ModuleNotFoundError: No module named 'PIL'
I've tried reading through other posts with similar issues and saw someone mention that I could have an alias that is pointing to a different python location, could that be the issue? How would I resolve that?
Make sure your virtual environment is activated
Command to activate virtual environment in linux an macOS:-
source venv_name/bin/activate
Command to activate virtual environment in windows:-
venv_name\Scripts\activate
I knew that pypy is faster than CPython so I wanted to try it and it is actually way faster than CPython, however when I install libraries it shows the following:
PS C:\Users\DELL\Desktop\telegram\python -work some-> pip install pillow
Requirement already satisfied: pillow in c:\users\dell\appdata\roaming\python\python39\site-
packages (8.3.0)
but when I try to import the module (pillow):
Traceback (most recent call last):
File "c:/Users/DELL/Desktop/telegram/python -work some-/studying code 2.py", line 1, in
<module>
import pillow
ModuleNotFoundError: No module named 'pillow'
it is not there! please help!
pillow is an up-to-date fork of the now deprecated Python Image Library (PIL). you need to import PIL or from PIL import ... to use it.
Check out their documentation to learn more!
You must run pip with the version of Python you want to install the package for. In this case, you need pypy3 -m pip install pillow or something similar---run it with the same interpreter as the script you'll run next. In your pasted output, we see Requirement already satisfied: pillow in c:\users\dell\appdata\roaming\python\python39\site-packages which is the path for CPython 3.9, not PyPy.
The PIL module should be installed because when I run the pip install pillow I get this message: Requirement already satisfied: pillow in [my installation route]. But, when I try to import this into a file, I get this error:
ModuleNotFoundError: No module named 'Pillow'
What am I doing wrong?
this has worked for me if your using vscode try install by typing py -m pip install pillow
from PIL import ImageTk,Image
Pillow is a fork of PIL, and the import is carried over.
import PIL
Should do the trick. The documentation has additional details:
https://pillow.readthedocs.io/en/stable/installation.html
I am currently trying to run a sample code I code off of the internet.
While trying to run it using python2.7, I get the following ERROR :
# python2.7 example.py
Traceback (most recent call last):
File "example.py", line 9, in <module>
from http.server import HTTPServer
ImportError: No module named http.server
I tried to run the following :
# pip install http.server
Collecting http.server
Could not find a version that satisfies the requirement http.server (from versions: )
No matching distribution found for http.server
But when I use python3, it does not give me the ERROR. Rather gives the ERROR :
# python3 example.py
Traceback (most recent call last):
File "example.py", line 13, in <module>
from prometheus.client import Gauge
ImportError: No module named 'prometheus.client'
Im trying to install prometheus.client using pip and pip3 but nothing.
# pip install prometheus.collectors
Collecting prometheus.collectors
Could not find a version that satisfies the requirement prometheus.collectors (from versions: )
No matching distribution found for prometheus.collectors
# pip3 install prometheus.collectors
Collecting prometheus.collectors
Could not find a version that satisfies the requirement prometheus.collectors (from versions: )
No matching distribution found for prometheus.collectors
How can I get the missing libraries ?
EDIT ::
In the below example I am using a very minimalist approach (again from github)
from prometheus_client import start_http_server, Summary
import random
import time
# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')
# Decorate function with metric.
#REQUEST_TIME.time()
def process_request(t):
"""A dummy function that takes some time."""
time.sleep(t)
if __name__ == '__main__':
# Start up the server to expose the metrics.
start_http_server(8000)
# Generate some requests.
while True:
process_request(random.random())
Running the above code yields :
# python3.4 main.yaml
Traceback (most recent call last):
File "main.yaml", line 1, in <module>
from prometheus_client import start_http_server, Summary
ImportError: No module named 'prometheus_client'
Whereas I do have the library installed.
# pip3 install prometheus_client
Requirement already satisfied: prometheus_client in /usr/lib/python2.7/site-packages
I'm running on ubuntu 18.10 and i got the same issue, and i have python2 install already. I was able to solved it by installing python3 and python3-pip like below.
sudo apt install python3
sudo apt install python3-pip
pip3 install prometheus_client
May be helpful to somebody!
http.server is a module in Python 3.
See the note for SimpleHTTPServer in Python 2:
Note The SimpleHTTPServer module has been merged into http.server in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.
For prometheus.client, you want pip install prometheus_client. See https://github.com/prometheus/client_python
README.md from the repository you linked states:
Deprecated, use: https://github.com/prometheus/client_python
I faced the exact same problem. I installed pip3 using python3 -m pip install --upgrade pip. After that ran pip3 install prometheus_client. After this, the issue got fixed.
sudo -H pip3 install prometheus_client
just worked for me
Found here
https://github.com/b-harvest/terra_oracle_voter_deprecated/issues/17
I have installed (actually reinstalled) scipy:
10_x86_64.whl (19.8MB): 19.8MB downloaded
Installing collected packages: scipy
Successfully installed scipy
But the misc subpackage is apparently not included?
16:03:28/shared $ipython
In [1]: from scipy.misc import imread
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-f9d3d927b58f> in <module>()
----> 1 from scipy.misc import imread
ImportError: cannot import name imread
What is the way to install the scipy.misc package?
I think you need to install PIL as well. From the scipy.misc docs:
Note that the Python Imaging Library (PIL) is not a dependency of SciPy and therefore the pilutil module is not available on systems that don’t have PIL installed.
I had same problem, running Python 2.7.12 on an old Windows XP/SP3 box. I had some stuff running on Python on MacBook, and wanted to make it work on an old Windows box. It can be done. The winbox had pip ver. 8, and I upgraded it to pip ver. 9, from within Python, using the suggestion pip provides when you run it. I had installed numpy and Pillow (current ver of PIL), using "pip install numpy" and "pip install Pillow", but "pip install scipy" and "pip install scipy.misc" failed with "no matching distribution found". I had to uninstall numpy, and then install two files: 1) numpy+mkl and then 2) scipy, both files installed are binaries for Windows, in .whl (wheel) archive format, downloaded from: http://www.lfd.uci.edu/~gohlke/pythonlibs/
site maitained by Christoph Gohlke. Find the binary versions you need for your flavour of Windows, and downloaded them into C:\some\directory. Installation order is important. First the numpy+mkl is installed, using pip, with the scipy file second. I downloaded the files from Gohlke's site, and then used pip to install them. For my old winbox, this was:
C:\some\directory\> pip install numpy-1.12.1rc1+mkl-cp27-cp27m-win32.whl
(you should see)
Installing collected packages: numpy
Successfully installed numpy-1.12.1rc1+mkl
(then, you can run)
C:\some\directory\> pip install scipy-0.18.1-cp27-cp27m-win32.whl
and you should see the "Successfully installed..." message. I had already installed Pillow.
Confirm by starting Python, and trying:
>>> import numpy as np
>>> from PIL import Image, ImageDraw
>>> import scipy.misc
and all these should work. You should be able to render a .jpg with:
image = Image.open("Somefile.jpg")
image.show()
and your somefile.jpg will be displayed.