在 Mac 上使用 macports python (python27) 安装 pyserial 时遇到问题

发布于 2024-12-20 01:18:07 字数 764 浏览 7 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘紸啶 2024-12-27 01:18:07

py-serial 是 python2.4 的端口,对于更高版本的 python 使用编号版本,例如

sudo port install py27-serial

这是一个历史错误 - 最初他们认为他们应该只有一个版本的 python 包,然后意识到你可以有多个版本的 python并且许多软件包都依赖于版本。

py-serial is the port for python2.4 for later versions of python use the numbered version e.g.

sudo port install py27-serial

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文