我安装了64位Windows 7和64位Python。
C:\Work\Python>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
我用这个安装了primesieve:
C:\Work\Python>pip install primesieve
Collecting primesieve
Using cached primesieve-1.3.0-cp36-cp36m-win_amd64.whl
Installing collected packages: primesieve
Successfully installed primesieve-1.3.0
然后我尝试运行一个Python程序/脚本 导入这个primesieve库但我收到此错误:
C:\Work\Python>run 500A
C:\Work\Python>python EulerProblem500A.py
Traceback (most recent call last):
File "EulerProblem500A.py", line 1, in <module>
import primesieve # pip install primesieve
File "C:\Programs\Python36\lib\site-packages\primesieve\__init__.py", line 1, in <module>
from primesieve._primesieve import *
ImportError: DLL load failed: %1 is not a valid Win32 application.
我不理解这个错误,因为OS,Python和primesieve库的版本都匹配。
有什么想法吗?!
答案 0 :(得分:-1)
查看源代码,您应该导入以下内容;
from libc.stdint cimport uint64_t, int64_t
from libcpp.vector cimport vector
cimport cpp_primesieve
好像是cython
<强>尝试强>:
pip install cython