在 Windows \ Linux CentOS 上为 Python3 安装 quickfix 模块

Installing quickfix module on Windows \ Linux CentOS for Python3

我一直在尝试在我的 Windows 机器和 CentOs VM 上安装 quickfix,但没有成功。

-> 在 Windows 10 中尝试: 已从 https://www.lfd.uci.edu/~gohlke/pythonlibs/#quickfix 成功安装 wheel 文件 在选择 wheel 文件之前检查 python 和体系结构的版本,能够顺利安装。当我在命令提示符下启动 python 和 运行 help("modules") 时,我能够看到 quickfix(并且所有版本都已安装)。

C:\Users\NickN\Downloads>python --version
Python 3.7.3

C:\Users\NickN\Downloads>pip install quickfix-1.15.1-cp37-cp37m-win_amd64.whl
Requirement already satisfied: quickfix==1.15.1 from file:///C:/Users/NickN/Downloads/quickfix-1.15.1-cp37-cp37m-win_amd64.whl in c:\python37\lib\site-packages (1.15.1)

但是,当我启动 Python 并尝试导入 quickfix 时...

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import quickfix as qf
Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\quickfix.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, 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 "<stdin>", line 1, in <module>
  File "C:\Python37\lib\site-packages\quickfix.py", line 21, in <module>
    _quickfix = swig_import_helper()
  File "C:\Python37\lib\site-packages\quickfix.py", line 20, in swig_import_helper
    return importlib.import_module('_quickfix')
  File "C:\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.

有人可以协助提供有关如何在 Windows 上安装 quickfix 的指导吗?

...不过,我确实听说 quickfix 不一定适用于 Windows,它更适合 Linux 环境。我已经尝试 运行 在 CentOs 中安装 pip,确保我安装了所有依赖项、开发工具和正确版本的 Python。仍然,没有运气....

在 CentOS 中出现以下错误:

[nickn@new-host bin]$ sudo pip install quickfix
Collecting quickfix
  Using cached quickfix-1.15.1.tar.gz (1.5 MB)
Using legacy 'setup.py install' for quickfix, since package 'wheel' is not installed.
Installing collected packages: quickfix
    Running setup.py install for quickfix ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nJvzBo/quickfix/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nJvzBo/quickfix/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4Bp3Vy/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python2.7/quickfix
         cwd: /tmp/pip-install-nJvzBo/quickfix/
    Complete output (38 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying quickfix.py -> build/lib.linux-x86_64-2.7
    copying quickfixt11.py -> build/lib.linux-x86_64-2.7
    copying quickfix40.py -> build/lib.linux-x86_64-2.7
    copying quickfix41.py -> build/lib.linux-x86_64-2.7
    copying quickfix42.py -> build/lib.linux-x86_64-2.7
    copying quickfix43.py -> build/lib.linux-x86_64-2.7
    copying quickfix44.py -> build/lib.linux-x86_64-2.7
    copying quickfix50.py -> build/lib.linux-x86_64-2.7
    copying quickfix50sp1.py -> build/lib.linux-x86_64-2.7
    copying quickfix50sp2.py -> build/lib.linux-x86_64-2.7
    running build_ext
    Testing for std::tr1::shared_ptr...
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYTHON_MAJOR_VERSION=2 -IC++ -I/usr/include/python2.7 -c test_std_tr1_shared_ptr.cpp -o test_std_tr1_shared_ptr.o
    ...found
    Testing for std::shared_ptr...
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -std=c++0x -DPYTHON_MAJOR_VERSION=2 -DHAVE_STD_TR1_SHARED_PTR -IC++ -I/usr/include/python2.7 -c test_std_shared_ptr.cpp -o test_std_shared_ptr.o
    ...found
    Testing for std::unique_ptr...
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -std=c++0x -DPYTHON_MAJOR_VERSION=2 -DHAVE_STD_TR1_SHARED_PTR -DHAVE_STD_SHARED_PTR -IC++ -I/usr/include/python2.7 -c test_std_unique_ptr.cpp -o test_std_unique_ptr.o
    ...found
    building '_quickfix' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/C++
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYTHON_MAJOR_VERSION=2 -DHAVE_STD_TR1_SHARED_PTR -DHAVE_STD_SHARED_PTR -DHAVE_STD_UNIQUE_PTR -IC++ -I/usr/include/python2.7 -c C++/HttpServer.cpp -o build/temp.linux-x86_64-2.7/C++/HttpServer.o -std=c++0x -Wno-deprecated -Wno-unused-variable -Wno-deprecated-declarations -Wno-maybe-uninitialized
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYTHON_MAJOR_VERSION=2 -DHAVE_STD_TR1_SHARED_PTR -DHAVE_STD_SHARED_PTR -DHAVE_STD_UNIQUE_PTR -IC++ -I/usr/include/python2.7 -c C++/TimeRange.cpp -o build/temp.linux-x86_64-2.7/C++/TimeRange.o -std=c++0x -Wno-deprecated -Wno-unused-variable -Wno-deprecated-declarations -Wno-maybe-uninitialized
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYTHON_MAJOR_VERSION=2 -DHAVE_STD_TR1_SHARED_PTR -DHAVE_STD_SHARED_PTR -DHAVE_STD_UNIQUE_PTR -IC++ -I/usr/include/python2.7 -c C++/ThreadedSSLSocketAcceptor.cpp -o build/temp.linux-x86_64-2.7/C++/ThreadedSSLSocketAcceptor.o -std=c++0x -Wno-deprecated -Wno-unused-variable -Wno-deprecated-declarations -Wno-maybe-uninitialized
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYTHON_MAJOR_VERSION=2 -DHAVE_STD_TR1_SHARED_PTR -DHAVE_STD_SHARED_PTR -DHAVE_STD_UNIQUE_PTR -IC++ -I/usr/include/python2.7 -c C++/ThreadedSocketInitiator.cpp -o build/temp.linux-x86_64-2.7/C++/ThreadedSocketInitiator.o -std=c++0x -Wno-deprecated -Wno-unused-variable -Wno-deprecated-declarations -Wno-maybe-uninitialized
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYTHON_MAJOR_VERSION=2 -DHAVE_STD_TR1_SHARED_PTR -DHAVE_STD_SHARED_PTR -DHAVE_STD_UNIQUE_PTR -IC++ -I/usr/include/python2.7 -c C++/QuickfixPython.cpp -o build/temp.linux-x86_64-2.7/C++/QuickfixPython.o -std=c++0x -Wno-deprecated -Wno-unused-variable -Wno-deprecated-declarations -Wno-maybe-uninitialized
    C++/QuickfixPython.cpp:175:21: fatal error: Python.h: No such file or directory
     # include <Python.h>
                         ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nJvzBo/quickfix/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nJvzBo/quickfix/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4Bp3Vy/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python2.7/quickfix Check the logs for full command output.

现在我知道 CentOs 错误是在 Python2 左右,但是,我在 CentOs 中安装了 python 版本并且链接指向正确的位置。

在这一点上,我什至会使用 quickfix 在我的冰箱上工作 Python1.... 请协助。

想通了!!!

Windows 解法:

导入模块失败的根本原因(在安装 wheel 文件时)是由于缺少 Visual C++ Redistributable for Visual Studio 2015。这在我尝试清理磁盘时被删除了 space 在我的 PC 上删除“过时软件”。但是,由于 QuickFIX 是用 C++ 编写的,因此您需要同时安装 Microsoft Visual C++ Redistributable 和 Microsoft Visual Compiler。 下载所有内容后,我可以立即毫无问题地导入 quickfix。

C:\Users\NickN>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import quickfix as qf
>>>

快速修复链接:https://www.lfd.uci.edu/~gohlke/pythonlibs/#quickfix

安装视频演练:https://www.youtube.com/watch?v=pAlrGJDvyYg&list=PLv-cA-4O3y95np0YK9NrKqNKLsORaSjBc&index=10

...当然,请检查以确保您安装了 Microsoft C++ 可执行文件!