运行 Python、Anaconda、Pandas、服务器上的 Numpy 离线获取依赖性错误

Run Python, Anaconda, Pandas, Numpy offline on a Server getting dependency error

在虚拟机上安装 Anaconda 后,我 运行 一个脚本可以在我的本地机器上运行,但不能在我的虚拟机上运行。

我收到错误消息:

C:\Users\...\python>"C:\ProgramData\Anaconda3\python.exe" "C:\Users\...\reporting.py"
C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init
Traceback (most recent call last):
  File "C:\Users\...\reporting.py", line 1, in <module>
    import pandas as pd
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.8 from "C:\ProgramData\Anaconda3\python.exe"
  * The NumPy version is: "1.18.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.

虚拟机没有互联网。有什么方法可以安装所有需要的库和框架吗?

您可以使用类似 Pyinstaller 的方式打包您的脚本和使用的库。当你使用 virtualenv 时请记住,你在 pyinstaller 执行期间使用的所有包都被存储并且可能导致巨大的 .exe