import serial - Linux Mint 17,64位,python3.5

时间:2016-11-19 17:44:48

标签: import python-3.5 pyserial

我将要问一个似乎已被多次询问过的问题。但是,其他人发布的所有解决方案似乎都没有起作用。这让我相信我的问题可能与系统有关,但我不是专家。

我是Python的新手,但不是Linux,也不是软件的新手。

我正在运行Linux Mint,17.3(Rosa),64位,并且最近每https://www.reddit.com/r/linuxquestions/comments/3nbfdx/how_to_upgrade_from_python_27_to_35_linux_mint/安装了Python3.5,这似乎有效。

Python 3.5.0 (default, Nov 19 2016, 10:27:39) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

运行时:     点子列表| grep pyserial 我得到以下内容:     pyserial(2.6)

我的问题只是这个:我无法运行以下pyPractice.py文件:

import serial

...使用以下cli提示符:

me@machine /home/me/Desktop/practice $ python3.5 pyPractice.py

我尝试了很多解决方案,例如在以下位置发布的解决方案,但似乎都因为某种原因而失败:

1)pyserial, ImportError: No module named serial

RESULT->已经安装了pyserial,如上所示。当我尝试安装' serial'时,没有骰子,无法识别

me@machine /home/me/Desktop/practice $ sudo pip install serial
[sudo] password for me:
Downloading/unpacking serial
  Could not find any downloads that satisfy the requirements serial
Cleaning up...
No distributions at all found for serial
Storing debug log for failure in /home/me/.pip/pip.log

2)Python ImportError: No module named serial

RESULT->几乎和上面一样。接近结束时,建议的修复方法是键入:

sudo apt-get install python3-serial

但是,我得到以下内容:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-serial is already the newest version.
The following package was automatically installed and is no longer required:
  php5
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 379 not upgraded.

3)Serial import python

RESULT->不确定......我开始看这个选项,但是你不知道,我的python3.5软件包中没有串口。所以,即使我确实有正确的路径,我也不知道从哪里开始。

我对Python很陌生,所以请随时回到基础。我并不反对阅读,所以链接到解释你的想法的网站是可以接受的。我对Linux非常方便。

[有点无用的旁注:我试图开始慢,但我试图通过运行一个简单的立方体绘图脚本,找到了here]

1 个答案:

答案 0 :(得分:0)

在第一种方法中有两个错误:对于Python 3,您应该使用命令pip3,并且该模块称为pyserial。 至于第二种方法,可能是包装安装不正确。尝试删除它并重新安装,可能使用选项--reinstall。也许命令sudo dpkg-reconfigure python3-serial会有所帮助。