简体   繁体   中英

How to install Charm-crypto library for python3 on windows 10?

I've installed GMP 5.x , PBC (latest) and OPENSSL but when I try `pip3 install charm-crypto this error occurs. If anyone knows how to solve this error because I don't understand it please tell me? By the way the error is much longer than this but I couldn't paste it, It is mostly repeating the process of copying

(venv) C:\Users\admin\PycharmProjects\Testing>pip3 install charm-crypto
Collecting charm-crypto
  Using cached Charm-Crypto-0.43.tar.gz (364 kB)
Requirement already satisfied: setuptools in c:\users\admin\pycharmprojects\testing\venv\lib\site-packages (from charm-crypto) (50.3.2)
Requirement already satisfied: pyparsing>=1.5.5 in c:\users\admin\pycharmprojects\testing\venv\lib\site-packages (from charm-crypto) (2.4.7)
Using legacy 'setup.py install' for charm-crypto, since package 'wheel' is not installed.
Installing collected packages: charm-crypto
    Running setup.py install for charm-crypto ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\admin\pycharmprojects\testing\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\admin\\AppData\
\Local\\Temp\\pip-install-83yi7s_w\\charm-crypto\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-83yi7s_w\\charm-crypto\\setup.py'"
'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
install --record 'C:\Users\admin\AppData\Local\Temp\pip-record-vq3a6qkl\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users
\admin\pycharmprojects\testing\venv\include\site\python3.9\charm-crypto'
         cwd: C:\Users\admin\AppData\Local\Temp\pip-install-83yi7s_w\charm-crypto\
    Complete output (194 lines):
    Platform: Windows
    Config file: config.mk
    Warning, using default config vaules.
    You probably want to run ./configure.sh first.
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    creating build\lib.win-amd64-3.9\charm
    copying charm\config.py -> build\lib.win-amd64-3.9\charm
    copying charm\__init__.py -> build\lib.win-amd64-3.9\charm
    creating build\lib.win-amd64-3.9\charm\core
    copying charm\core\__init__.py -> build\lib.win-amd64-3.9\charm\core
    creating build\lib.win-amd64-3.9\charm\core\crypto
    copying charm\core\crypto\__init__.py -> build\lib.win-amd64-3.9\charm\core\crypto
    copying charm\adapters\abenc_adapt_hybrid.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\dabenc_adapt_hybrid.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\ibenc_adapt_hybrid.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\ibenc_adapt_identityhash.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\kpabenc_adapt_hybrid.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\pkenc_adapt_bchk05.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\pkenc_adapt_chk04.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\pkenc_adapt_hybrid.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\pksig_adapt_naor01.py -> build\lib.win-amd64-3.9\charm\adapters
    copying charm\adapters\__init__.py -> build\lib.win-amd64-3.9\charm\adapters
    running build_ext
    building 'charm.core.math.pairing' extension
    creating build\temp.win-amd64-3.9
    creating build\temp.win-amd64-3.9\Release
    creating build\temp.win-amd64-3.9\Release\charm
    creating build\temp.win-amd64-3.9\Release\charm\core
    creating build\temp.win-amd64-3.9\Release\charm\core\benchmark
    creating build\temp.win-amd64-3.9\Release\charm\core\math
    creating build\temp.win-amd64-3.9\Release\charm\core\math\pairing
    creating build\temp.win-amd64-3.9\Release\charm\core\utilities
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DBENCHMARK_E
NABLED=1 -Icharm/core/utilities/ -Icharm/core/benchmark/ -Ic:\users\admin\pycharmprojects\testing\venv\include -IC:\Users\admin\AppData\Local\Programs\Python\Python3
9\include -IC:\Users\admin\AppData\Local\Programs\Python\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\
ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\include -IC:\Program Files (x86)\Windows Kits\10\include\10
.0.18362.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um -IC:\Program Fi
les (x86)\Windows Kits\10\include\10.0.18362.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt /Tccharm/core/benchmark/benchmarkmodule.c
 /Fobuild\temp.win-amd64-3.9\Release\charm/core/benchmark/benchmarkmodule.obj
    benchmarkmodule.c
    C:\Users\admin\AppData\Local\Temp\pip-install-83yi7s_w\charm-crypto\charm\core\benchmark\benchmarkmodule.h(12): fatal error C1083: Impossible d'ouvrir le fichier
 includeÿ: 'sys/time.h'ÿ: No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\cl.exe' failed with exit cod
e 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\admin\pycharmprojects\testing\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0]
= '"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-83yi7s_w\\charm-crypto\\setup.py'"'"'; __file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-8
3yi7s_w\\charm-crypto\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(c
ode, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\admin\AppData\Local\Temp\pip-record-vq3a6qkl\install-record.txt' --single-version-externally-managed --co
mpile --install-headers 'c:\users\admin\pycharmprojects\testing\venv\include\site\python3.9\charm-crypto' Check the logs for full command output.

The problem is there is file with code which is not compatible with MSVC. sys/time.h is included in benchmarkmodule.h and unfortunately this file does not exit in MSVC.

Try to install mingw, set the CC to mingw compiler and run the pip3 command . If it still not working you can try to build it directly like explained in https://jhuisi.github.io/charm/install_source.html .

In all cases you will need a mingw compiler. However, it may be complicated.
You will need to install the msvc redistributable. When you run the make command, f you face the error Unknown MS Compiler version 1927 . modify the cygwinccompiler.py file by adding :

#custom add
elif msc_ver == '1927':
    # VS2019 / MSVC 16.7
    return ['msvcr100'] 
#custom add

before the last add. You may also need to add a file distutils.cfg like explained in https://wiki.python.org/moin/WindowsCompilers . Once these modifications done, the compilation should start normally.

Perhaps the easiest would be to compile it under linux.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM