通过Anaconda Prompt vs CMD运行Python / Pickle

时间:2019-06-10 22:50:57

标签: python anaconda pickle

以下是我尝试使用CMD.exe运行我的python脚本时遇到的错误

Microsoft Windows [Version 10.0.17134.765]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for p in sys.path: print(p)
...

C:\Users\Garrett\Anaconda3\python37.zip
C:\Users\Garrett\Anaconda3\DLLs
C:\Users\Garrett\Anaconda3\lib
C:\Users\Garrett\Anaconda3
C:\Users\Garrett\AppData\Roaming\Python\Python37\site-packages
C:\Users\Garrett\Anaconda3\lib\site-packages
C:\Users\Garrett\Anaconda3\lib\site-packages\win32
C:\Users\Garrett\Anaconda3\lib\site-packages\win32\lib
C:\Users\Garrett\Anaconda3\lib\site-packages\Pythonwin
>>> import pickle
>>> import os
>>> import sys
>>> filename_FB = 'C:/xampp/htdocs/PD/model/final_gam_FB.sav'
>>> pitchType = 'FB'
>>> V = 90
>>> HB = 12.66
>>> VB = 4.5
>>> U = 0.3
>>> appr_diff = -1.17
>>> with open(filename_FB,'rb') as file: loaded_model_FB = pickle.load(file)
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Garrett\Anaconda3\lib\site-packages\pygam\__init__.py", line 7, in <module>
    from pygam.pygam import GAM
  File "C:\Users\Garrett\Anaconda3\lib\site-packages\pygam\pygam.py", line 10, in <module>
    import numpy as np
  File "C:\Users\Garrett\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\Garrett\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
>>>

下面是我尝试使用Anaconda Prompt成功运行相同代码的尝试。

(base) C:\Users\Garrett>python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for p in sys.path: print(p)
...

C:\Users\Garrett\Anaconda3\python37.zip
C:\Users\Garrett\Anaconda3\DLLs
C:\Users\Garrett\Anaconda3\lib
C:\Users\Garrett\Anaconda3
C:\Users\Garrett\AppData\Roaming\Python\Python37\site-packages
C:\Users\Garrett\Anaconda3\lib\site-packages
C:\Users\Garrett\Anaconda3\lib\site-packages\win32
C:\Users\Garrett\Anaconda3\lib\site-packages\win32\lib
C:\Users\Garrett\Anaconda3\lib\site-packages\Pythonwin
>>> import pickle
>>> import os
>>> import sys
>>> filename_FB = 'C:/xampp/htdocs/PD/model/final_gam_FB.sav'
>>> pitchType = 'FB'
>>> V = 90
>>> HB = 12.66
>>> VB = 4.5
>>> U = 0.3
>>> appr_diff = -1.17
>>> with open(filename_FB,'rb') as file: loaded_model_FB = pickle.load(file)
...
>>>

我正在VSCode中运行此脚本,并且正在使用CMD作为终端,我希望保持这种方式。此过程也适用于Jupyter笔记本。

0 个答案:

没有答案