简体   繁体   English

如何让VSCode的终端识别python

[英]How to get VSCode's terminal to recognize python

I'm just getting started with learning python and this is my first project.我刚刚开始学习 python,这是我的第一个项目。 I'm trying to write a bot for a simple game and I'm trying to run a command in the terminal at the bottom of vs code to check if pyautogui is installed correctly in my workspace.我正在尝试为一个简单的游戏编写一个机器人,并尝试在 vs 代码底部的终端中运行一个命令,以检查 pyautogui 是否正确安装在我的工作区中。 I can do "pip list" from my computers terminal and I see pyautogui from the list but vscode terminal window says我可以从我的计算机终端执行“pip list”,我从列表中看到 pyautogui 但 vscode 终端 window 说

The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct, and try again.

At line:1 char:1在行:1 字符:1

  • pip list pip列表
  •  + CategoryInfo: ObjectNotFound: (pip:String) [], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException

Thanks for the feedback感谢您的反馈

VScode uses a virtual environment, so you have to install the modules from VScode. VScode 使用虚拟环境,因此您必须从 VScode 安装模块。

try to use pip3 instead of pip (if you use python3.x).尝试使用 pip3 而不是 pip(如果您使用 python3.x)。 otherwise try to install pip with 'python get -pip.py'.否则尝试使用“python get -pip.py”安装 pip。

This has happened to me a few times before and I believe that it is a path issue in Windows.这在我之前发生过几次,我相信这是 Windows 中的路径问题。 So, the easiest way to fix this is to let Anaconda do it for you.因此,解决此问题的最简单方法是让 Anaconda 为您完成。

Go this link: https://www.anaconda.com/products/individual#windows Go 这个链接: https://www.anaconda.com/products/individual#windows

Then, click on the download button.然后,单击下载按钮。 Once it is downloaded, the installer will ask if you would like to let Anaconda modify your path, say yes.下载后,安装程序会询问您是否要让 Anaconda 修改您的路径,说是。 Let anaconda make the alterations that it needs.让 anaconda 进行所需的更改。

Then, restart your visual studios code and try pip again.然后,重新启动您的 Visual Studio 代码并再次尝试 pip。

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

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