简体   繁体   English

如何更改 python 模块路径?

[英]How change python module path?

I want to use the Scrapy Python module and because I have anaconda installed, scrapy is installed.我想使用 Scrapy Python 模块,因为我安装了 anaconda,所以安装了 scrapy。 However, I don't want to use the anaconda environment I want to use VSCode.但是,我不想使用 anaconda 环境我想使用 VSCode。 I type "pip install scrapy" but it returns "Requirement already satisfied".我输入“pip install scrapy”,但它返回“要求已经满足”。 How do I change the path way of this module because I can't run Scrapy in VSCode.我如何更改此模块的路径方式,因为我无法在 VSCode 中运行 Scrapy。

It gives me a "report missing imports" error but I already have it installed.它给了我一个“报告缺少导入”错误,但我已经安装了它。

I already tried to uninstall and reinstall but that didn't work.我已经尝试卸载并重新安装,但没有用。

Python allows you to modify the module search path at runtime by modifying the sys.path variable. Python 允许您通过修改 sys.path 变量在运行时修改模块搜索路径。 This allows you to store module files in any folder of your choice.这允许您将模块文件存储在您选择的任何文件夹中。 Since the sys.path is a list, you can append a search-path to it.由于 sys.path 是一个列表,您可以 append 搜索它的路径。

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

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