如何在 Mac 的 VS 代码中安装 Python 模块

阿德里安盐

过去 3 小时一直在尝试这样做,但根本没有成功。

我想在 MAC BOOK PRO 上的 VS Code 中安装 Python 模块。

我输入命令pip3 install matplotlibpip3 install keyboard并且没有任何效果。这似乎是这个星球上最糟糕的 IDE。当我清楚地下载了它时,我一直在终端窗口中收到名为“matplotlib”No module的消息我在这里附上一个屏幕截图。不工作时的截图

ALSO - I Do NOT want to run in a virtual environment. I want to use the modules in any program I run. I cannot program without getting round this issue so any help would be greatly appreciated ! I am very new to Python in VS code.

Lex Li

Python works pretty bad for beginners IMHO, especially when people usually have no idea that both Python 2 and 3 are there (and even more minor versions on the same machines for whatever reasons).

Learn the python version being used

For your current folder opened in VSCode, 3.8.2 64 bit is used and shown in the status bar, so click it and check the popup list at top to learn what are the Python executable paths available on this machine.

You should choose /usr/bin/python3 from the list, as that's usually the default many people is using right now.

在该配置之后,VSCode 会坚持该可执行文件以定位所有模块等。

安装模块

现在你知道Python可执行文件的路径,安装一个模块很简单,

/usr/bin/python3 -m pip install some.module

pip以这种方式调用避免了与其他方法的所有混乱(因为它们可以简单地为您鼻子下的另一个 Python 可执行文件安装模块)。

这应该足以让您开始您的 Python 之旅,但还远远不足以确保您可以编写脚本并调试它们。

理想情况下,找一位老师/导师或只是一个比你更有 Python 经验的人来指导你。那么你就不需要在小事上浪费时间了。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章