简体   繁体   English

Visual Studio 代码未运行 Python 3

[英]Visual studio Code not running Python 3

My computer: MacBook Air M1 Running 11.6.3 Memory 8GB我的电脑:MacBook Air M1 Running 11.6.3 Memory 8GB

Things I have tried:我尝试过的事情:

  1. Reinstalled Visual studio code重新安装 Visual Studio 代码

  2. Use pyenv to install Python 3.10.2使用pyenv安装Python 3.10.2

  3. pyenv install 3.10 pyenv 安装 3.10

  4. pyenv global 3.10 pyenv 全球 3.10

  5. Had brew reinstall pyenv 2.2.4有 brew 重新安装 pyenv 2.2.4

  6. Also tried command python3.10 -V just reverts back to python 2.7 right away.还尝试了命令 python3.10 -V 立即恢复到 python 2.7。

Every time I open Visual studio code, to get python 3 to run I must run the two commands below.每次我打开 Visual Studio Code 时,要运行 python 3,我必须运行下面的两个命令。 Just wondering if there is a more permanent solution to the problem.只是想知道是否有更永久的解决方案来解决这个问题。 Once I run the command, I have no problems, and can run python programs normally, but the next time I restart Visual studio code, the same issue comes back.运行命令后没有问题,可以正常运行python个程序,但下次重启Visual Studio Code时,又出现同样的问题。 Any solution would be helpful... many thanks!!任何解决方案都会有所帮助......非常感谢!

alias python="python3" # to use python3 rather than python2.7 alias python="python3" # 使用 python3 而不是 python2.7

alias idle="idle3" # to use python3 idle rather than 2.7 alias idle="idle3" # 使用 python3 idle 而不是 2.7

Simply running the command python3.10 fixed the problem.只需运行命令 python3.10 即可解决问题。 I was just using python nameoffile.py to run a program.我只是使用 python nameoffile.py 来运行一个程序。 Not aware that VSC was defaulting to Python 2.7 built into the Mac OS.不知道 VSC 默认为 Python 2.7 内置于 Mac OS。

python3.10 nameoffile.py python3.10 nameofffile.py

Many Thanks everyone非常感谢大家

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM