[英]Using VSCode on Mac, can't get Python 3.8 to run, only Python 2.7.16
I just downloaded VSCode on my Mac as well as Python and pip.我刚刚在我的 Mac 上下载了 VSCode 以及 Python 和 pip。 I downloaded the latest version of Python via VS Microsoft extensions, and installed pip using python -m ensurepip --upgrade.
我通过VS Microsoft扩展下载了最新版本的Python,并使用python -m ensurepip --upgrade安装了pip。 I have python 2.7.16 on my Mac as well I believe from my OS (it's not something I downloaded).
我的 Mac 上也有 python 2.7.16 我相信我的操作系统(这不是我下载的东西)。 I am trying to use pip and Python in VSCode.
我正在尝试在 VSCode 中使用 pip 和 Python 。 I have my interpreter in my virtual environment set to Python 3.8.2 and I created the virtual environment using "python3 -m venv.venv".
我将虚拟环境中的解释器设置为 Python 3.8.2,并使用“python3 -m venv.venv”创建了虚拟环境。 However, every time I check the python version (with python --version) in the terminal it returns Python 2.7.16.
但是,每次我在终端中检查 python 版本(使用 python --version)时,它都会返回 Python 2.7.16。 I check the pip version and there is no command found.
我检查了 pip 版本,没有找到命令。 When I check the pip3 version I get back the following warning:
当我检查 pip3 版本时,我收到以下警告:
WARNING: pip is being invoked by an old script wrapper.警告:旧脚本包装器正在调用 pip。 This will fail in a future version of pip.
这将在 pip 的未来版本中失败。 Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
请参阅https://github.com/pypa/pip/issues/5599以获取有关解决基本问题的建议。 To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
为避免此问题,您可以使用“-m pip”调用 Python,而不是直接运行 pip。 pip 21.3.1 from /Users/username/Library/Python/3.8/lib/python/site-packages/pip (python 3.8)
pip 21.3.1 来自 /Users/username/Library/Python/3.8/lib/python/site-packages/pip (python 3.8)
Whenever I try to run python -m pip or python -m pip3 it returns "no module named pip".每当我尝试运行 python -m pip 或 python -m pip3 时,它都会返回“没有名为 pip 的模块”。
When installing python I got a warning that Python 3 was not on the PATH, but when I tried to add the path it did not fix the issue.安装 python 时,我收到一条警告说 Python 3 不在 PATH 上,但是当我尝试添加路径时,它并没有解决问题。 I don't have a lot of experience adding a path so I may have done that incorrectly.
我没有太多添加路径的经验,所以我可能做错了。
Finally, I installed streamlit via pip3.最后,我通过 pip3 安装了 streamlit。 It resulted in the following message, but seemed to install.
它导致以下消息,但似乎已安装。 When I tried to import streamlit in my code it could not be resolved.
当我尝试在我的代码中导入 streamlit 时,它无法解决。
WARNING: pip is being invoked by an old script wrapper.警告:旧脚本包装器正在调用 pip。 This will fail in a future version of pip.
这将在 pip 的未来版本中失败。 Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
请参阅https://github.com/pypa/pip/issues/5599以获取有关解决基本问题的建议。 To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
为避免此问题,您可以使用“-m pip”调用 Python,而不是直接运行 pip。 Defaulting to user installation because normal site-packages is not writeable
默认为用户安装,因为普通站点包不可写
How do I add Python 3 to my PATH and ensure that VSCode is running Python 3 instead of 2?如何将 Python 3 添加到我的 PATH 并确保 VSCode 正在运行 Python 3 而不是 2?
Simply always refer 'python3' rather than 'python'.只需始终引用“python3”而不是“python”。
python3 --version
python3 -m pip install blahblahblah
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.