简体   繁体   English

安装枕头后无法导入PIL

[英]Can't import PIL after installing Pillow

I have python 3.x, and was told to install Pillow for image manipulation. 我有python 3.x,并被告知要安装Pillow进行图像处理。 After installing it with pip however, i'm unable to import PIL from the python interpreter. 但是,使用pip安装它之后,我无法从python解释器导入PIL。 It just says ImportError: No module named 'PIL' . 它只是说ImportError: No module named 'PIL' Running pip list in the command line shows that Pillow is indeed installed. 在命令行中运行pip list表示确实安装了Pillow。

使用easy_install而不是pip后,它最终正确安装。

You might have used pip for a different python executable. 您可能已将pip用于其他python可执行文件。 To make sure that the correct pip command is used, run: 要确保使用正确的pip命令,请运行:

$ python3 -m pip install pillow

I don't really have the time or the means to create an entire virtual machine just for the purposes of testing this one problem. 我真的没有时间或方法来创建整个虚拟机,仅用于测试这一问题。

virtualenv is not a virtual machine. virtualenv不是虚拟机。 All you need to create a virtualenv from scratch: 从头开始创建virtualenv所需的全部:

$ python3 -m pip install --user virtualenv # install package
$ python3 -m virtualenv venv # create virtualenv named 'venv'

Then to activate the created virtualenv on POSIX system : 然后在POSIX系统上激活创建的virtualenv

$ source venv/bin/activate # activate on POSIX

Or on Windows: 或在Windows上:

C:\> venv\Scripts\activate

Now, python , pip commands refers to the virtualenv. 现在, pythonpip命令引用了virtualenv。 To deactivate virtualenv, run: 要停用virtualenv,请运行:

$ deactivate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM