Python 如何从Jupyter的枕头导入图像?

Python 如何从Jupyter的枕头导入图像?,python,matplotlib,import,python-imaging-library,jupyter,Python,Matplotlib,Import,Python Imaging Library,Jupyter,我正在尝试从枕头导入图像 from PILLOW import Image im = Image.open("bride.jpg") im.rotate(45).show() Undefined function 'from' for input arguments of type 'char'. >> import PIL.Image im = Image.open("bride.jpg") im.rotate(45).show() Error using import

我正在尝试从枕头导入图像

    from PILLOW import Image
im = Image.open("bride.jpg")
im.rotate(45).show()
Undefined function 'from' for input arguments of type 'char'.

>> import PIL.Image
im = Image.open("bride.jpg")
im.rotate(45).show()
Error using import
Import argument 'PIL.Image' cannot be found or cannot be imported.
类型为“char”的输入参数的未定义函数“from”

我总是犯同样的错误。我是否使用了错误的导入语句

编辑:
我注意到了另外一件事。当我浏览我的C:/drive并查看Pip和PIL等所在的文件夹时。里面什么都没有。即使当我把一个有东西的文件复制到那个区域,打开那个新文件,我也看不到里面的任何东西。但当我复制它时,绿色条会显示正在传输的数据

守则:

例如:

    enter code here
from PIL import Image, ImageEnhance
# Main imports/Initialization
%matplotlib inline
import matplotlib
from matplotlib import animation, rc
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from IPython.display import HTML
import numpy as np
from PIL import Image, ImageEnhance
import requests
from io import BytesIO
from copy import deepcopy
from scipy.spatial import distance
from scipy.interpolate import UnivariateSpline
from copy import deepcopy
​
# Default figure size in notebook
matplotlib.rcParams['figure.figsize'] = (6,6)
matplotlib.rcParams['image.aspect'] = 'equal'
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-16-7c75157a7886> in <module>
      7 from IPython.display import HTML
      8 import numpy as np
----> 9 from PIL import Image, ImageEnhance
     10 import requests
     11 from io import BytesIO

ModuleNotFoundError: No module named 'PIL'
在此处输入代码
从PIL导入图像,图像增强
#主要导入/初始化
%matplotlib内联
导入matplotlib
从matplotlib导入动画,rc
将matplotlib.pyplot作为plt导入
从matplotlib.pyplot导入imshow
从IPython.display导入HTML
将numpy作为np导入
从PIL导入图像,图像增强
导入请求
从io导入字节io
从复制导入deepcopy
从scipy.spatial导入距离
从scipy.interpolate导入单变量样条线
从复制导入deepcopy
​
#笔记本中的默认数字大小
matplotlib.rcParams['figure.figsize']=(6,6)
matplotlib.rcParams['image.aspect']='equal'
---------------------------------------------------------------------------
ModuleNotFoundError回溯(上次最近调用)
在里面
7从IPython.display导入HTML
8作为np进口numpy
---->9从PIL导入图像,图像增强
10项进口申请
11从io导入字节io
ModuleNotFoundError:没有名为“PIL”的模块
您不工作的原因是您的
requirements.txt
如下所示:

matplotlib==2.0.2
requests==2.20.0
Pillow==5.0.0
numpy==1.13.0
scipy==0.19.0
pandas==0.20.2
scikit-learn==0.18.1
tzlocal-1.5.1
这一行:

tzlocal-1.5.1

可能会破坏绑定器的依赖关系。另一件事是,这些是非常特定的版本,可能会生成太特定的依赖项(参考)。我建议将其更改为:

matplotlib
requests
pillow
numpy
scipy
pandas
scikit-learn
tzlocal
至少我这么做的时候你的活页夹开始工作了


在本地,您只需在管理员命令提示符下运行
pip install-r requirements.txt
,本地Jupyter安装就会自动运行,至少在我将笔记本克隆到Windows虚拟机时是这样

这是一个关于如何在matlab中加载图像(以任何形式)或如何从“枕头”加载图像的问题吗?不符合你的目的?不确定。我用的是一个预先制作好的笔记本,它比这个更复杂。它导入了一些东西,但import命令似乎不起作用。为什么from不起作用?如果你对上述问题的回答是“不确定”,你需要做更多的工作。请参考并使用示例。这与matlab有什么关系?如果你在matlab中输入这些命令,它们肯定不起作用,请解释你的意思。上面链接的文件不应该在matlab中运行吗?!?我试试看,等一下。Sudo做了什么?我仍然得到相同的回答:导入参数“PIL.Image”找不到或无法导入。我注意到了其他一些事情。当我浏览我的C:/drive并查看Pip和PIL等所在的文件夹时。里面什么都没有。即使当我把一个有东西的文件复制到那个区域,打开那个新文件,我也看不到里面的任何东西。当我复制它时,绿色的条显示数据正在传输。如果你看一下上面的链接,代码甚至不能在线工作,更不用说我的电脑了。