简体   繁体   English

导入包“ imutil”可在PyCharm和python终端中运行,但不能在Windows终端中运行

[英]Importing package “imutil” works in PyCharm and python terminal but not windows terminal

In Pycharm (runs on Python 3.7), I am doing this Computer Visions tutorial which requires the package imutils. 在Pycharm(在Python 3.7上运行)中,我正在执行此Computer Visions教程,该教程需要使用软件包imutils。 The interesting thing is that if I run this file named "neural_style_transfer", it works fine. 有趣的是,如果我运行此名为“ neural_style_transfer”的文件,则可以正常工作。 But according to the tutorial we must run the following in the windows terminal 但是根据教程,我们必须在Windows终端中运行以下命令

neural_style_transfer.py --image images/giraffe.jpg \
--model models/eccv16/the_wave.t7

When I run that, it says "no module name imutils". 当我运行它时,它说“没有模块名imutils”。

Some more background: For some reason, when I use the IDE spyder, there is also no module named imutils. 更多背景知识:由于某种原因,当我使用IDE spyder时,也没有名为imutils的模块。 But I think it is because my spyder is still in python 3.6. 但我认为这是因为我的spyder仍在python 3.6中。 My imutils is definitely located in the python 3.7 packages stuff, I can find it at: 我的imutils绝对位于python 3.7软件包中,我可以在以下位置找到它:

C:\Users\andre\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\imutils

Found the solution! 找到了解决方案! Anyways, you have to call: 无论如何,您必须致电:

py -m pip install imutils in your terminal py -m pip在终端中安装imutils

The logical explanation I found is this: I have 3 versions of pythons on my computer: 2.7, 3.6, 3.7. 我发现的逻辑解释是:我的计算机上有3个版本的python:2.7、3.6、3.7。 I have 3.6 because tensorflow doesn't support python 3.7 yet. 我有3.6,因为tensorflow还不支持python 3.7。 But if you only call pip install imutils, it only downloads imutils to your python 3.7 site packages, which is not shared across all the python versions and is not the version I use when I do deeplearning. 但是,如果仅调用pip install imutils,则只会将imutils下载到您的python 3.7站点包中,该站点包不会在所有python版本中共享,也不是我进行深度学习时使用的版本。 Therefore, to download imutils to python 3.6 (the version I use), use py -m pip install imutils . 因此,要将imutils下载到python 3.6(我使用的版本),请使用py -m pip install imutils

There's still many potholes in my conjecture though: for example, py-m pip install sounds like it doesn't specify downloading to 3.6, so why does it download to 3.6? 但是我的猜想仍然有很多毛病:例如,py-m pip install听起来好像没有指定下载到3.6,那么为什么下载到3.6? And, for most of the time, I thought I was working on python 3.7, which should had imutils installed, but maybe I was working on 3.6 instead of 3.7. 而且,在大多数时候,我以为我正在使用python 3.7进行工作,应该安装了imutils,但是也许我在3.6而不是3.7上工作。

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

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