我在 Ubuntu 16.04 LTS 上使用 Python 3.5。
我将我的 python 文件保存在/home/me/Python
其中,我想使用 .pth 文件让 python 搜索该目录,所以我custompaths.pth
在第 1 行创建并输入 /home/me/Python。
我尝试保存custompaths.pth
在几个不同的目录中,所有这些目录都在sys.path
,但是如果我尝试导入testmod.py
位于的模块(),/home/me/Python
我只会得到:
ImportError: No module named 'testmod'
我尝试保存testmod.py
在我尝试过的相同目录中custompaths.pth
,然后它导入就好了。
我还尝试了不同的方法来输入搜索路径custompaths.pth
:
/home/me/Python/
/home/me/Python
home/me/Python
home/me/Python/
'/home/me/Python/'
我在这里错过了什么吗?