在 Mac 上使用 macports python (python27) 安装 pyserial 时遇到问题
我使用 macports (在我的 mac 上)安装了 py-serial,但它安装了 python24 而不是使用我现有的 python27。
因此,如果使用 macports py-serial 安装的 python24 那么我可以导入 py-serial
# /opt/local/bin/python2.4 -c 'import serial'
但我无法使用其中任何一个将其导入 python27
# /opt/local/bin/python2.7 -c 'import serial'
# python -c 'import serial'
我收到此错误
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named serial
我确保我选择了正确的版本:
# port select --set python python27
我仍然尝试卸载并重新安装它给出与上面相同的错误
# sudo port uninstall
# port install py-serial
我认为这是与我的 macports/python 有关的问题,而不是 py-serial。任何帮助表示赞赏。
I installed py-serial using macports (on my mac) but it installed python24 instead of using my existing python27.
So if use the python24 that macports py-serial installed then I can import py-serial
# /opt/local/bin/python2.4 -c 'import serial'
But I cannot import it into python27 using either of these
# /opt/local/bin/python2.7 -c 'import serial'
# python -c 'import serial'
I get this error
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named serial
I made sure I have the correct version selected:
# port select --set python python27
I tried uninstall and reinstall it still gives the same error as above
# sudo port uninstall
# port install py-serial
I think this is a problem related to my macports/python, not py-serial. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
py-serial 是 python2.4 的端口,对于更高版本的 python 使用编号版本,例如
这是一个历史错误 - 最初他们认为他们应该只有一个版本的 python 包,然后意识到你可以有多个版本的 python并且许多软件包都依赖于版本。
py-serial is the port for python2.4 for later versions of python use the numbered version e.g.
It is an historical error - originally they thought they should just have one version of python packages then it was realised that you could have multiple versions of python and that many packages are version dependant.