Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
758 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 reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...