导入numpy时出现以下错误:
Traceback (most recent call last):
File "/home/xxx/Projects/Reinforcement-Learning/cardgame/reinforcement_learning_agent.py", line 3, in <module>
import numpy as np
File "/home/xxx/environments/machinelearning/lib/python3.5/site-packages/numpy/__init__.py", line 126, in <module>
from numpy.__config__ import show as show_config
File "/home/xxx/environments/machinelearning/lib/python3.5/site-packages/numpy/__config__.py", line 9, in <module>
os.environ["PATH"] += os.pathsep + extra_dll_dir
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'PATH'
我可以想象一下,在处理虚拟环境时,我必须做些什么。
答案 0 :(得分:3)
似乎这个问题已经修复但修复程序尚未发布:
在修复程序生效之前,我刚刚在我的代码中实现了修复程序作为解决方法:
# before importing numpy add 'PATH' to os.environ
import os
os.environ.setdefault('PATH', '')
import numpy as np