[英]ModuleNotFoundError: No module named 'serial' after pip install pyserial
When trying to run a .py file from a command prompt I am getting the error, 当尝试从命令提示符运行.py文件时,出现错误,
File "C:\\Users\\mayna\\Anaconda3\\lib\\site-packages\\lucidIo\\Com.py", line 7, in import serial ModuleNotFoundError: No module named 'serial'
导入串行ModuleNotFoundError中的文件“ C:\\ Users \\ mayna \\ Anaconda3 \\ lib \\ site-packages \\ lucidIo \\ Com.py”,第7行:没有名为“ serial”的模块
This is even after I have installed the pyserial module using 即使在我使用以下方法安装了pyserial模块之后
pip install pyserial
The following line, pip list modules
shows that pyserial 3.4 is in fact installed yet for some reason when I try to import serial in a command prompt it gives me the module not found error. 下面的行,
pip list modules
显示pyserial 3.4实际上已经安装,但是由于某种原因,当我尝试在命令提示符下导入serial时,它给了我模块未找到的错误。 The thing that is really throwing me off is that when I directly open a python window and try accessing serial I get this, 真正让我失望的是,当我直接打开python窗口并尝试访问serial时,我得到了这一点,
>>> import serial
>>> serial
<module 'serial' from 'C:\\Users\\mayna\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\serial\\__init__.py'>
I am not sure where to go from here, I am new to python but from what I have already researched I should not be getting this error anymore. 我不确定从这里去哪里,我是python的新手,但是根据我已经研究的内容,我不应该再遇到此错误。 I am running python 3.7 on a windows 10 pc.
我在Windows 10 PC上运行python 3.7。
Any help would be greatly appreciated. 任何帮助将不胜感激。 Thank you.
谢谢。
(Removing comments and adding it as an answer) (删除评论并将其添加为答案)
Since you have anaconda installed, try this: 由于您已安装anaconda,请尝试以下操作:
conda install pyserial
or
conda install -c conda-forge pyserial
The main reason for this issue would be, that your pip is installing this module in a separate location or to the python's other version in your machine. 造成此问题的主要原因是,您的pip将此模块安装在单独的位置,或者安装到计算机中python的其他版本。 And you are running Python, maybe on Jupyter or some other IDE which runs via Anaconda.
您正在运行Python,也许是在Jupyter或通过Anaconda运行的其他IDE上。 So using above conda install, will install all the dependencies in the required continuum folder from where conda IDEs intake the modules.
因此,使用上述conda install,将所有依赖项安装在conda IDE从中获取模块的所需continuum文件夹中。 No, you don't need to uninstall anything mayna, just run the above command in cmd and it should work.
不,您不需要卸载任何mayna,只需在cmd中运行以上命令即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.