当我们从C:/ rootdir运行测试时,我们的测试失败了,但是当我们在C:/ rootdir / tests / our_module /中单独运行一个测试时,它失败了,并在下面显示了一个很长的错误跟踪。肯定是由导入在我们的第24行触发的:
from podpac.datalib.terraintiles import TerrainTiles
错误跟踪:
platform win32 -- Python 3.7.8, pytest-6.0.2, py-1.9.0, pluggy-0.13.1 --
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\lazy_import\__init__.py:149: in __getattribute__
return type(self)._lazy_import_callables[attr]
E KeyError: '__path__'
During handling of the above exception, another exception occurred:
tests\our_module\test_dcp.py:13: in <module>
???
our_module\dcp.py:24: in <module>
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\podpac\__init__.py:44: in <module>
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\podpac\core\node.py:23: in <module>
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\podpac\core\units.py:37: in <module>
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\podpac\core\style.py:9: in <module>
???
<frozen importlib._bootstrap>:983: in _find_and_load
???
<frozen importlib._bootstrap>:959: in _find_and_load_unlocked
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\lazy_import\__init__.py:156: in __getattribute__
_load_module(self)
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\lazy_import\__init__.py:510: in _load_module
reload_module(module)
C:\Users\user\anaconda3\envs\our_module\lib\importlib\__init__.py:169: in reload
_bootstrap._exec(spec, module)
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\matplotlib\__init__.py:912: in <module>
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\matplotlib\__init__.py:602: in matplotlib_fname
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\matplotlib\__init__.py:599: in gen_candidates
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\matplotlib\__init__.py:239: in wrapper
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\matplotlib\__init__.py:502: in get_configdir
???
C:\Users\user\anaconda3\envs\our_module\lib\site-packages\matplotlib\__init__.py:444: in _get_xdg_config_dir
???
C:\Users\user\anaconda3\envs\our_module\lib\pathlib.py:1088: in home
return cls(cls()._flavour.gethomedir(None))
C:\Users\user\anaconda3\envs\our_module\lib\pathlib.py:267: in gethomedir
raise RuntimeError("Can't determine home directory")
E RuntimeError: Can't determine home directory
我对要做的事情感到困惑。我尝试将C:/ rootdir / tests / out_module /添加到sys.path,但是失败完全相同。我正在使用其他可能使用matplotlib
的软件包,例如numpy
/ pandas
/ sklearn
,所以我不确定这是否会导致导入问题-我在导入podpac之后其他所有内容都是由于在某些模块之前导入时发生了奇怪的导入错误。带有unicode
冲突声明的内容。
答案 0 :(得分:1)
通过在模块顶部运行此按钮来解决
os.environ['HOME'] = os.curdir
相信这个问题的答案Laravel to Python RuntimeError: Can't determine home directory