2017-05-02 3 views
0

tensorflow를 사용하여 MNIST 예측을 실행하려고합니다.CMD 줄 오류 Tensorflow 실행

파일 :

https://github.com/niektemme/tensorflow-mnist-predict/ 

CMD 라인 코드 : I 오류없이 PyCharm에서 프로그램을 실행할 수 있지만 명령 행을 통해 스크립트를 실행하려고 할 때, 내가 얻을

python predict_1.py ‘number1.png’ 

오류. 내가 pip3 목록을 확인

Traceback (most recent call last): 
    File "predict_1.py", line 29, in <module> 
    import tensorflow as tf 
ModuleNotFoundError: No module named 'tensorflow' 

가 설치 확인 : tensorflow (1.0.1)

갱신 1 :

나는 두 환경에서이 테스트를 실행 :. 수입 OS 인쇄 (운영 체제를 파일을)

CMD 라인 :

C:\ProgramData\Anaconda3\lib\os.py 

갱신 2 :

내가 환경 변수에서 Anaconda3을 제거하고

CMD 라인이 지금 읽고는 :

C:\Users\\AppData\Local\Programs\Python\Python35\lib\os.py 

이 오류 I입니다 CMD 라인을 통해 tensorflow를 실행하려고 시도하십시오 :

Traceback (most recent call last): 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper 
    return importlib.import_module(mname) 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
    File "<frozen importlib._bootstrap>", line 986, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 969, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked 
    File "<frozen importlib._bootstrap>", line 666, in _load_unlocked 
    File "<frozen importlib._bootstrap>", line 577, in module_from_spec 
    File "<frozen importlib._bootstrap_external>", line 906, in create_module 
    File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed 
ImportError: DLL load failed: The specified module could not be found. 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 54, in <module> 
    from tensorflow.python import pywrap_tensorflow 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module> 
    _pywrap_tensorflow = swig_import_helper() 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper 
    return importlib.import_module('_pywrap_tensorflow') 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
ImportError: No module named '_pywrap_tensorflow' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "predict_1.py", line 29, in <module> 
    import tensorflow as tf 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\__init__.py", line 24, in <module> 
    from tensorflow.python import * 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 60, in <module> 
    raise ImportError(msg) 
ImportError: Traceback (most recent call last): 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper 
    return importlib.import_module(mname) 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
    File "<frozen importlib._bootstrap>", line 986, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 969, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked 
    File "<frozen importlib._bootstrap>", line 666, in _load_unlocked 
    File "<frozen importlib._bootstrap>", line 577, in module_from_spec 
    File "<frozen importlib._bootstrap_external>", line 906, in create_module 
    File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed 
ImportError: DLL load failed: The specified module could not be found. 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 54, in <module> 
    from tensorflow.python import pywrap_tensorflow 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module> 
    _pywrap_tensorflow = swig_import_helper() 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper 
    return importlib.import_module('_pywrap_tensorflow') 
    File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
ImportError: No module named '_pywrap_tensorflow' 


Error importing tensorflow. Unless you are using bazel, 
you should not try to import tensorflow from its source directory; 
please exit the tensorflow source tree, and relaunch your python interpreter from there. 
+0

당신은'python -v'와'which python' (또는'where where python' on windows?)을 할 수 있습니까? 아마도 당신이 알고있는 다른 python 설치에서 실행 중일 것입니다. –

+0

Python 3.5 Windows –

+0

'python'은 python 설치 디렉토리로 연결됩니다. "tensorflow"가 "lib \ site-packages"에 있는지 확인하십시오. –

답변

0

편집 결과에 따르면 두 개의 개별 python 설치가 있습니다. 하나는 Users\AppData이고 다른 하나는 ProgramData\Anaconda3입니다. PyCharm은 첫 번째 명령을 사용하지만 CLI에서 python 명령을 실행하면 두 번째 명령이 실행됩니다. 이 문제를 해결하는 방법은 두 가지가 있습니다. 첫 번째 설치를 가리 키도록 PATH 변수를 조정할 수 있으므로 CLI의 python은 PyCharm과 동일하거나 두 번째 설치시 TensorFlow를 설치할 수 있습니다 (이 경우 두 번째 설치시 TensorFlow를 설치할 수 있습니다. 코드에 의존하는 다른 라이브러리). 다음은 PATH 변수 (https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/)를 편집하는 방법에 대한 링크입니다. C:\Users\\AppData\Local\Programs\Python\Python35이 여기에 있고 C:\ProgramData\Anaconda3이 아닌지 확인하고 싶습니다.