我使用 pip install Some_lib 安装了我的 python 环境。在我的开发环境中,我有一个名为 Some_lib 的文件夹,我想执行 python -m Some_lib 以便执行当前文件夹,而不是我在 python 环境中安装的先例 Some_lib。可能吗?
最佳答案
我认为 python -s -m Some_lib
应该按照 the documentation 的建议工作:
-s
Don’t add the user site-packages directory tosys.path
.
但是您在导入其他模块时可能会遇到问题...
编辑:实际上当前工作目录版本默认优先于
-m
[...] As with the-c
option, the current directory will be added to the start ofsys.path
.
所以 python -m Some_lib
也应该可以工作。
关于python -m 当前目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56042795/