Python ImportError: No module named serial

吃可爱长大的小学妹 提交于 2019-12-11 10:41:31

问题


I have installed Python 2.7.5 on Ubuntu 12.4 on a DELL LATITUDE E4300 64 bit and ran:

sudo pip install pyserial

nevertheless when running:

sudo python main.py 

I receive the following error message:

Traceback (most recent call last):
  File "main.py", line 4, in <module>
    from mySerial import *
  File "/home/oscar/ath10k/tools/sanity_test/src/mySerial.py", line 6, in <module>
    import serial
ImportError: No module named serial

I looked on other posts but none of them helped me to solve this problem. I don't know what else to do I also ran:

sudo -H pip install pyserial

and

sudo pip install pyserial --upgrade

Any help will be greatly appreciated.

Kind regards.

Oscar.


回答1:


On my ubuntu 14.4 with python 2.7 as default, I installed pyserial for python3 (which my IDE is using actually) with the help of following command:

 sudo apt-get install python3-serial



回答2:


Your script name is exactly like module name, change mySerial.py to something else.




回答3:


I solved this by installing pyserial from source code instead than doing it with pip.

I do not know why it works this way and when using pip it prints error messages.



来源:https://stackoverflow.com/questions/29012189/python-importerror-no-module-named-serial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!