简体   繁体   English

Visual Studio代码中的Python模块

[英]Python modules in visual studio code

How to download python modules in visual studio code? 如何在Visual Studio代码中下载python模块? I have tried to download using pip but vs-code uses windows cmd/PowerShell therefore pip didn't work. 我尝试使用pip下载,但vs代码使用Windows cmd / PowerShell,因此pip无法正常工作。

Your best solution is to create a virtual environment for your project and then install into that. 最好的解决方案是为项目创建一个虚拟环境,然后将其安装到其中。 So if you're on Windows and don't have access to pip then you probably used the python.org installer and don't have python3 on your path either. 因此,如果您在Windows上并且没有访问pip权限,则可能使用了python.org安装程序,并且路径上也没有python3 In that case you can do py -m venv .venv to create a virtual environment (this is assuming you're using Python 3). 在这种情况下,您可以执行py -m venv .venv来创建虚拟环境(假设您使用的是Python 3)。 Once that's created you will want to select the virtual environment (see the environments documentation on how to do that). 创建完成后,您将需要选择虚拟环境(有关如何执行操作,请参阅环境文档 )。

That gets you a proper environment to develop in. From there you can open a terminal with Python: Create Terminal and that will automatically activate the virtual environment, putting python on your path so you can use python -m pip install to install your dependencies ( pip will also be there, but it's better to use python -m pip to help make sure you're installing into the Python interpreter you expect). 这样可以为您提供合适的开发环境。从那里可以使用Python: Create Terminal打开一个终端Python: Create Terminal ,它将自动激活虚拟环境,将python放在路径上,以便可以使用python -m pip install安装依赖项( pip也将存在,但最好使用python -m pip来确保您要安装到期望的Python解释器中。

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

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