简体   繁体   English

在 Visual Studio 中将目录添加到 PATH

[英]Adding a directory to PATH in visual studio

I'm trying to add a bunch of libraries to python while using visual studio.我正在尝试在使用 Visual Studio 时向 python 添加一堆库。 I downloaded python using the microsoft store, but have downloaded everything else using pip, which doesn't download to the same place.我使用 microsoft store 下载了 python,但使用 pip 下载了其他所有内容,但不会下载到同一个地方。 How do I adjust the path, or where do I need to move files to ensure that I can import everything properly?如何调整路径,或者我需要将文件移动到哪里以确保我可以正确导入所有内容?

Open workspace Settings.json, add打开workspace Settings.json,添加

"python.analysis.extraPaths": [
    "\the folder that contains modules\",
]

Then in python file, before importing modules, add然后在python文件中,在导入模块之前,添加

import sys
sys.path.append("\the folder that contains modules\")

See the following picture, there's no discord in current interpreter and with above settings and code, it can be import successfully. discord ,当前的解释器没有discord ,有了上面的设置和代码,就可以成功导入了。 Please have a try.请试一试。 在此处输入图片说明

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

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