Programming

ImportError : PIL이라는 모듈이 없습니다

procodes 2020. 6. 1. 20:59
반응형

ImportError : PIL이라는 모듈이 없습니다


쉘에서이 명령을 사용하여 PIL을 설치합니다.

easy_install PIL

그런 다음 이것을 실행 python하고 입력하십시오 : import PIL. 하지만이 오류가 발생합니다.

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named PIL

그런 문제가 없었어요, 어떻게 생각하세요?


일부 PIL 설치에서는 다음을 수행해야합니다.

import Image

대신 import PIL(PIL은 항상이 방법으로 가져 오지는 않습니다). import Image당신을 위해 일하기 때문에 , 이것은 실제로 PIL을 설치했음을 의미합니다.

라이브러리와 Python 모듈의 이름이 다른 경우는 드물지만 PIL (일부 버전)에 대해 선택된 것입니다.

공식 튜토리얼 에서이 모듈을 사용하는 방법에 대한 자세한 정보를 얻을 수 있습니다 .

추신 : 실제로 일부 설치 import PIL 에서는 작동 하지 않아 혼란을 초래합니다. 이것은 @JanneKarila가 찾은 문서예제 와 최신 버전의 MacPorts PIL 패키지 (1.1.7)에 의해 확인됩니다.


쉘에서 다음을 실행하십시오.

pip install Pillow

주의 : PIL은 더 이상 사용되지 않으며 베개 는 후속 제품입니다.


다른 말로, 필자는 PIL과 역 호환되며 새로운 시스템에서 더 잘 유지 관리 / 작동하는 Pillow 사용을 강력히 권장합니다 .

설치되면 할 수 있습니다

import PIL 

또는

from PIL import Image

기타..


처음에 베개를 설치

pip install Pillow

또는 다음과 같이

c:\Python35>python -m pip install Pillow

그런 다음 파이썬 코드에서 호출 할 수 있습니다

from PIL import Image

"Pillow는 더 이상 유지 보수되지 않는 Python Imaging Library 인 PIL의 포크입니다. 그러나 이전 버전과의 호환성을 유지하기 위해 이전 모듈 이름이 사용됩니다." 에서 베개 설치되어 있지만 "베개라는 이름의 모듈"- python2.7 - 윈도우 7 - 파이썬은 베개를 설치하지 -m


때로는 파이썬에서 Unitest를 실행하는 이러한 유형의 오류가 발생합니다. 해결책은 가상 환경에서 동일한 패키지를 제거하고 설치하는 것입니다.

이 명령을 사용하여 :

pip uninstall PIL

pip install  PIL 

어떤 이유로 오류가 발생하면 명령 시작 부분에 sudo를 추가하고 Enter 키를 누른 후 비밀번호를 입력하십시오.


이것은 Ubuntu 16.04에서 나를 위해 일했습니다.

sudo apt-get install python-imaging

약 30 분 동안 검색 한 후 Wikibooks 에서이 사실을 발견했습니다 .


아나콘다를 사용하는 경우 :

conda install pillow

Windows에서는 PIL 라이브러리의 위치에 대한 경로를 확인하십시오. 내 시스템에서 경로가

\Python26\Lib\site-packages\pil instead of \Python26\Lib\site-packages\PIL  

pil폴더 이름을로 변경 한 후 PILPIL 모듈을로드 할 수있었습니다.


파이썬 패키지와 함께 이미지와 베개를 설치해야합니다.

유형

python -m pip install image 

또는 명령 프롬프트 (Windows)를 실행 한 다음 스크립트 폴더로 이동하십시오.

cd C:\Python27\Scripts

그런 다음 아래 명령을 실행하십시오.

pip install image

파이썬 패키지와 함께 이미지와 베개를 설치해야합니다. 명령 줄은 모든 것을 처리해 줄 것입니다.

히트

python -m pip 설치 이미지


PIL 사용 베개 대신 작동

easy_install Pillow

또는

pip install Pillow

나는 사용했다 :

pip install Pillow 

pip는 Lib \ site-packages에 PIL을 설치했습니다. PIL을 Lib로 옮길 때 모든 것이 잘 작동했습니다. 저는 Windows 10을 사용하고 있습니다.


Windows에서는 다운로드하여 .exe를 설치해야합니다.

https://pypi.python.org/pypi/Pillow/2.7.0


I used conda-forge to install pillow version 5, and that seemed to work for me:

conda install --channel conda-forge pillow=5

the normal conda install pillow did NOT work for me.


I had the same issue while importing PIL and further importing the ImageTk and Image modules. I also tried installing PIL directly through pip. but not success could be achieved. As in between it has been suggested that PIL has been deprectaed, thus, tried to install pillow through pip only. pillow was successfully installed, further, the PIL package was made under the path : python27/Lib/site-packages/.

Now both Image and ImageTk could be imported.


I recently installed Leap. I Tried openshot and it didn't start. So came here and found a suggestion to start from the Terminal to see if there were any error.

The error I had was error missing mlt. So I installed the python-mlt module from Yast and imported it, tried to start but next openshot said missing pil.

I Followed the Pillow suggestion to install because Yast couldn't find any pil and imported pil. That went ok but did not start and showed Error missing goocanvas.

The I installed goocanvas with Yast, imported it in python, and Openshot fired up !!

With a lot of errors in the terminal like missing Vimeoclient and lots of attributeerrors. Well, will see if it is of any influence working with it.


I had the same problem and i fixed it by checking what version pip (pip3 --version) is, then realizing I'm typing python<uncorrect version> filename.py instead of python<correct version> filename.py


On windows 10 I managed to get there with:

cd "C:\Users\<your username>\AppData\Local\Programs\Python\Python37-32" 
python -m pip install --upgrade pip     <-- upgrading from 10.something to 19.2.2.
pip3 uninstall pillow
pip3 uninstall PIL
pip3 install image

after which in python (python 3.7 in my case) this works fine...

import PIL
from PIL import image

You are probably missing the python headers to build pil. If you're using ubuntu or the likes it'll be something like

apt-get install python-dev

참고URL : https://stackoverflow.com/questions/8863917/importerror-no-module-named-pil

반응형