Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
760 views
in Technique[技术] by (180 points)

python 命令行运行时 import 提示某个自己写的模块不存在

出现这样情况一般是没有设定环境变量引起,python运行时会从指定的目录下加载模块,如果不指定自己的包路径将从默认环境变量中查询依赖包,这就可能出现实际本地包存在,但运行时确报import的包找不到的情况

widows下设置环境变量比较简单,可以直接在windows属性高级-环境变量中添加PYTHONPATH,也可以使用set命令设置临时环境变量,示例:

set PYTHONPATH=%PYTHONPATH%;D:\workspace\TestCase;C:\Python27\Scripts;C:\Python27;

Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...