我使用keras和theano作为后端在Windows 10上构建神经网络。我的python版本是2.7。问题是,当我尝试使用keras时,我不断收到路径错误。
$python
>>import keras
给我错误
Problem occurred during compilation with the command line below:
"g++" -shared -g -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -I"C:\Python27\lib\site-packages\numpy\core\include" -I"C:\Python27\include" -I"C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\gof" -L"C:\Python27\libs" -L"C:\Python27" -o C:\Users\Patrick\AppData\Local\Theano\compiledir_Windows-10-10.0.14393-Intel64_Family_6_Model_61_Stepping_4_GenuineIntel-2.7.11-64\lazylinker_ext\lazylinker_ext.pyd C:\Users\Patrick\AppData\Local\Theano\compiledir_Windows-10-10.0.14393-Intel64_Family_6_Model_61_Stepping_4_GenuineIntel-2.7.11-64\lazylinker_ext\mod.cpp -lpython27
The system cannot find the path specified.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\keras-2.0.3-py2.7.egg\keras\__init__.py", line 3, in <module>
from . import activations
File "C:\Python27\lib\site-packages\keras-2.0.3-py2.7.egg\keras\activations.py", line 4, in <module>
from . import backend as K
File "C:\Python27\lib\site-packages\keras-2.0.3-py2.7.egg\keras\backend\__init__.py", line 70, in <module>
from .theano_backend import *
File "C:\Python27\lib\site-packages\keras-2.0.3-py2.7.egg\keras\backend\theano_backend.py", line 3, in <module>
import theano
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\__init__.py", line 66, in <module>
from theano.compile import (
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\compile\__init__.py", line 10, in <module>
from theano.compile.function_module import *
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\compile\function_module.py", line 21, in <module>
import theano.compile.mode
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\compile\mode.py", line 10, in <module>
import theano.gof.vm
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\gof\vm.py", line 662, in <module>
from . import lazylinker_c
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\gof\lazylinker_c.py", line 127, in <module>
preargs=args)
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\gof\cmodule.py", line 2316, in compile_str
(status, compile_stderr.replace('\n', '. ')))
. ception: Compilation failed (return status=1): The system cannot find the path specified.
>>>
我可以告诉我需要添加到我的系统变量路径(至少我是这么认为......)但是无论我添加什么,我仍然会得到错误。我试过添加
C:\Python27\lib
C:\Python27\lib\site-packages
基本上它所说的任何路径都无法指定。需要注意的是,我在安装scipy时遇到了很多麻烦,不得不从http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy获取.whl文件,不确定是否有帮助。那是我的问题。
答案 0 :(得分:0)
我也面临同样的问题,并解决了删除其他python版本。确保只安装了1个python。如果有多个,有时候事情就不会很好。
答案 1 :(得分:0)
我建议在使用conda的单独环境中使用keras。
假设您要创建一个名为“ myenv”的环境
1.打开Anaconda promt并输入以下内容:
conda create --name myenv
2。要激活环境:
conda activate myenv
3。现在您可以安装keras和其他依赖项:
pip install keras
按如下所示安装tensorflow。
pip install tensorflow==2.0.0