所以这是一个奇怪的一个... 我承认,我安装我自己的模块无法摆脱鬼模块的
- 蟒蛇的野生混合的setup.py安装
- 蟒蛇setup.py开发
- pip安装。
- pip install -e。
但我不能识别在使用'pip卸载'并手动删除任何剩余的蛋或蛋链接,甚至* .pth文件中的条目后导入我的模块(planet4)的剩余能力的来源。
我尝试了很明显的:planet4.__file__
但这是空的:
In [12]: planet4.__file__
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-12-09c196cdfffe> in <module>()
----> 1 planet4.__file__
AttributeError: module 'planet4' has no attribute '__file__'
的Python仍然认为这是一个模块:
In [16]: type(planet4)
Out[16]: module
,当我尝试使用pkg_resources
去一些隐藏的文件路径我得到最奇怪的错误,即使谷歌只看过几次,至少与删除一个包:
In [10]: import pkg_resources as pr
In [11]: pr.resource_exists('planet4', 'data')
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-11-3ac559fe861b> in <module>()
----> 1 pr.resource_exists('planet4', 'data')
/Users/klay6683/miniconda3/envs/py35/lib/python3.5/site-packages/setuptools-19.6.2-py3.5.egg/pkg_resources/__init__.py in resource_exists(self, package_or_requirement, resource_name)
1137 def resource_exists(self, package_or_requirement, resource_name):
1138 """Does the named resource exist?"""
-> 1139 return get_provider(package_or_requirement).has_resource(resource_name)
1140
1141 def resource_isdir(self, package_or_requirement, resource_name):
/Users/klay6683/miniconda3/envs/py35/lib/python3.5/site-packages/setuptools-19.6.2-py3.5.egg/pkg_resources/__init__.py in has_resource(self, resource_name)
1603
1604 def has_resource(self, resource_name):
-> 1605 return self._has(self._fn(self.module_path, resource_name))
1606
1607 def has_metadata(self, name):
/Users/klay6683/miniconda3/envs/py35/lib/python3.5/site-packages/setuptools-19.6.2-py3.5.egg/pkg_resources/__init__.py in _has(self, path)
1658 def _has(self, path):
1659 raise NotImplementedError(
-> 1660 "Can't perform this operation for unregistered loader type"
1661 )
1662
NotImplementedError: Can't perform this operation for unregistered loader type
有人有什么想法我可以尝试吗?
那里有很多,所以我先避开了它。但后来我在那里看到了一个意外的文件夹,并想到了我过去使用PYTHONPATH的经验并进行了进一步调查。正如我在我的文章中写的,我确实检查了.pth文件。 –
我仍然给你答案,最后是b/c,如果指向模块的指针没有告诉你自己,这是真正实现它的唯一方法。 –