2

我无法开始pip install scrypt工作,在阅读了一轮之后,我尝试安装 Visual Studio 2017,但没有成功,然后我尝试按照Windows 编译器中的示例进行操作

MinGW-w64 是一个替代 C/C++ 编译器,适用于所有 Python 版本,最高 3.4。

Install Win-builds into C:\MinGW_w64.

Open Win-builds, switch to install at least binutils, gcc, gcc-g++, getext, mingw-w64, win-iconv, winpthreads, zlib, and click Process.

Add C:\MinGW_w64\bin to the PATH environment variable.

Create a distutils.cfg file with the following contents in the folder \Lib\distutils in Python install directory : 

[build] compiler=mingw32

[build_ext] compiler=mingw32

这产生了这个新的错误,

Running setup.py install for scrypt ... error
    Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\never\\appdata\\local\\temp\\pip-install-0ssspt\\scrypt\\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\never\appdata\local\temp\pip-record-uncdtb\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-2.7
    copying scrypt.py -> build\lib.win-amd64-2.7
    running build_ext
    building '_scrypt' extension
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    creating build\temp.win-amd64-2.7\Release\src
    creating build\temp.win-amd64-2.7\Release\scrypt-1.1.6
    creating build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib
    creating build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib\crypto
    creating build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib\scryptenc
    creating build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib\util
    C:\MinGW_w64\bin\gcc.exe -mdll -O -Wall -DHAVE_CONFIG_H -Iscrypt-1.1.6 -Iscrypt-1.1.6/lib -Iscrypt-1.1.6/lib/scryptenc -Iscrypt-1.1.6/lib/crypto -Iscrypt-1.1.6/lib/util -Ic:\OpenSSL-Win32\include -Ic:\python27\include -Ic:\python27\PC -c src/scrypt.c -o build\temp.win-amd64-2.7\Release\src\scrypt.o
    C:\MinGW_w64\bin\gcc.exe -mdll -O -Wall -DHAVE_CONFIG_H -Iscrypt-1.1.6 -Iscrypt-1.1.6/lib -Iscrypt-1.1.6/lib/scryptenc -Iscrypt-1.1.6/lib/crypto -Iscrypt-1.1.6/lib/util -Ic:\OpenSSL-Win32\include -Ic:\python27\include -Ic:\python27\PC -c scrypt-1.1.6/lib/crypto/crypto_aesctr.c -o build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib\crypto\crypto_aesctr.o
    C:\MinGW_w64\bin\gcc.exe -mdll -O -Wall -DHAVE_CONFIG_H -Iscrypt-1.1.6 -Iscrypt-1.1.6/lib -Iscrypt-1.1.6/lib/scryptenc -Iscrypt-1.1.6/lib/crypto -Iscrypt-1.1.6/lib/util -Ic:\OpenSSL-Win32\include -Ic:\python27\include -Ic:\python27\PC -c scrypt-1.1.6/lib/crypto/crypto_scrypt-nosse.c -o build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib\crypto\crypto_scrypt-nosse.o
    C:\MinGW_w64\bin\gcc.exe -mdll -O -Wall -DHAVE_CONFIG_H -Iscrypt-1.1.6 -Iscrypt-1.1.6/lib -Iscrypt-1.1.6/lib/scryptenc -Iscrypt-1.1.6/lib/crypto -Iscrypt-1.1.6/lib/util -Ic:\OpenSSL-Win32\include -Ic:\python27\include -Ic:\python27\PC -c scrypt-1.1.6/lib/crypto/sha256.c -o build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib\crypto\sha256.o
    C:\MinGW_w64\bin\gcc.exe -mdll -O -Wall -DHAVE_CONFIG_H -Iscrypt-1.1.6 -Iscrypt-1.1.6/lib -Iscrypt-1.1.6/lib/scryptenc -Iscrypt-1.1.6/lib/crypto -Iscrypt-1.1.6/lib/util -Ic:\OpenSSL-Win32\include -Ic:\python27\include -Ic:\python27\PC -c scrypt-1.1.6/lib/scryptenc/scryptenc.c -o build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib\scryptenc\scryptenc.o
    scrypt-1.1.6/lib/scryptenc/scryptenc.c: In function 'getsalt':
    scrypt-1.1.6/lib/scryptenc/scryptenc.c:214:4: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'DWORD' [-Wformat=]
        printf("%x", error);
        ^
    scrypt-1.1.6/lib/scryptenc/scryptenc.c:170:9: warning: unused variable 'buflen' [-Wunused-variable]
      size_t buflen = 32;
             ^
    scrypt-1.1.6/lib/scryptenc/scryptenc.c:168:10: warning: unused variable 'lenread' [-Wunused-variable]
      ssize_t lenread;
              ^
    scrypt-1.1.6/lib/scryptenc/scryptenc.c:167:6: warning: unused variable 'fd' [-Wunused-variable]
      int fd;
          ^
    C:\MinGW_w64\bin\gcc.exe -mdll -O -Wall -DHAVE_CONFIG_H -Iscrypt-1.1.6 -Iscrypt-1.1.6/lib -Iscrypt-1.1.6/lib/scryptenc -Iscrypt-1.1.6/lib/crypto -Iscrypt-1.1.6/lib/util -Ic:\OpenSSL-Win32\include -Ic:\python27\include -Ic:\python27\PC -c scrypt-1.1.6/lib/scryptenc/scryptenc_cpuperf.c -o build\temp.win-amd64-2.7\Release\scrypt-1.1.6\lib\scryptenc\scryptenc_cpuperf.o
    scrypt-1.1.6/lib/scryptenc/scryptenc_cpuperf.c:42:8: error: redefinition of 'struct timespec'
     struct timespec {
            ^
    In file included from c:\mingw_w64\x86_64-w64-mingw32\include\time.h:277:0,
                     from c:\mingw_w64\x86_64-w64-mingw32\include\sys\time.h:10,
                     from scrypt-1.1.6/lib/scryptenc/scryptenc_cpuperf.c:31:
    c:\mingw_w64\x86_64-w64-mingw32\include\sys\timeb.h:90:8: note: originally defined here
     struct timespec {
            ^
    error: command 'C:\\MinGW_w64\\bin\\gcc.exe' failed with exit status 1

    ----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\never\\appdata\\local\\temp\\pip-install-0ssspt\\scrypt\\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\never\appdata\local\temp\pip-record-uncdtb\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\never\appdata\local\temp\pip-install-0ssspt\scrypt\

任何人对我下一步应该做什么有任何想法,我有点迷茫。

编辑

我试过 Arnav Poddar 的建议,我得到了:

PS C:\> python -m easy_install scrypt
Searching for scrypt
Reading https://pypi.org/simple/scrypt/
Downloading https://files.pythonhosted.org/packages/80/3d/141eb80e754b86f6c25a2ffaf6c3af3acdb65a3e3700829a05ab0c5d965d/scrypt-0.8.13.tar.gz#sha256=1377b1adc98c4152694bf5d7e93b41a9d2e9060af69b747cfad8c93ac426f9ea
Best match: scrypt 0.8.13
Processing scrypt-0.8.13.tar.gz
Writing c:\users\never\appdata\local\temp\easy_install-vjtgij\scrypt-0.8.13\setup.cfg
Running scrypt-0.8.13\setup.py -q bdist_egg --dist-dir c:\users\never\appdata\local\temp\easy_install-vjtgij\scrypt-0.8.13\egg-dist-tmp-knuekj
no previously-included directories found matching 'build'
no previously-included directories found matching 'doc\build'
no previously-included directories found matching '*\__pycache__'
warning: no previously-included files matching '*.py[cod]' found anywhere in distribution
warning: no previously-included files matching '*.egg' found anywhere in distribution
warning: no previously-included files matching '*.egg-info' found anywhere in distribution
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.bak' found anywhere in distribution
warning: no previously-included files matching '*.swp' found anywhere in distribution
In file included from scrypt-1.2.1/lib/scryptenc/scryptenc.h:32:0,
                 from src/scrypt.c:30:
scrypt-windows-stubs/include/stdint.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
 #error "Use this header only with Microsoft Visual C++ compilers!"
  ^
In file included from scrypt-1.2.1/lib/crypto/crypto_scrypt.h:32:0,
                 from src/scrypt.c:31:
scrypt-windows-stubs/include/stdint.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
 #error "Use this header only with Microsoft Visual C++ compilers!"
  ^
In file included from scrypt-1.2.1/lib/crypto/crypto_scrypt.h:33:0,
                 from src/scrypt.c:31:
scrypt-windows-stubs/include/unistd.h:39:27: error: conflicting types for 'int8_t'
 typedef __int8            int8_t;
                           ^
In file included from scrypt-1.2.1/lib/scryptenc/scryptenc.h:32:0,
                 from src/scrypt.c:30:
scrypt-windows-stubs/include/stdint.h:75:30: note: previous declaration of 'int8_t' was here
    typedef signed char       int8_t;
                              ^
error: Setup script exited with error: command 'C:\\MinGW_w64\\bin\\gcc.exe' failed with exit status 1

我删除了 distutils.cfg 并再次运行:

PS C:\Python27\Lib\distutils> python -m easy_install scrypt
Searching for scrypt
Reading https://pypi.org/simple/scrypt/
Downloading https://files.pythonhosted.org/packages/80/3d/141eb80e754b86f6c25a2ffaf6c3af3acdb65a3e3700829a05ab0c5d965d/scrypt-0.8.13.tar.gz#sha256=1377b1adc98c4152694bf5d7e93b41a9d2e9060af69b747cfad8c93ac426f9ea
Best match: scrypt 0.8.13
Processing scrypt-0.8.13.tar.gz
Writing c:\users\never\appdata\local\temp\easy_install-uvqac3\scrypt-0.8.13\setup.cfg
Running scrypt-0.8.13\setup.py -q bdist_egg --dist-dir c:\users\never\appdata\local\temp\easy_install-uvqac3\scrypt-0.8.13\egg-dist-tmp-4u7_4h
no previously-included directories found matching 'build'
no previously-included directories found matching 'doc\build'
no previously-included directories found matching '*\__pycache__'
warning: no previously-included files matching '*.py[cod]' found anywhere in distribution
warning: no previously-included files matching '*.egg' found anywhere in distribution
warning: no previously-included files matching '*.egg-info' found anywhere in distribution
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.bak' found anywhere in distribution
warning: no previously-included files matching '*.swp' found anywhere in distribution
scrypt.c
crypto_scrypt_smix_sse2.c
crypto_scrypt_smix.c
crypto_scrypt.c
scryptenc.c
scrypt-1.2.1/lib/scryptenc/scryptenc.c(125) : warning C4244: '=' : conversion from 'size_t' to 'double', possible loss of data
scryptenc_cpuperf.c
memlimit.c
sha256.c
crypto_aes_aesni.c
crypto_aes.c
crypto_aesctr.c
crypto_entropy.c
entropy.c
scrypt-1.2.1/libcperciva/util/entropy.c(32) : warning C4101: 'lenread' : unreferenced local variable
scrypt-1.2.1/libcperciva/util/entropy.c(31) : warning C4101: 'fd' : unreferenced local variable
insecure_memzero.c
warnp.c
scrypt-1.2.1/libcperciva/util/warnp.c(39) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
        C:\Users\Never\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Include\string.h(207) : see declaration of 'strdup'
scrypt-1.2.1/libcperciva/util/warnp.c(59) : warning C4996: 'strerror': This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Users\Never\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Include\string.h(126) : see declaration of 'strerror'
humansize.c
asprintf.c
scrypt-1.2.1/libcperciva/util/asprintf.c(20) : warning C4996: 'vsnprintf': This function or variable may be unsafe. Consider using vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Users\Never\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Include\stdio.h(350) : see declaration of 'vsnprintf'
scrypt-1.2.1/libcperciva/util/asprintf.c(34) : warning C4996: 'vsnprintf': This function or variable may be unsafe. Consider using vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        C:\Users\Never\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Include\stdio.h(350) : see declaration of 'vsnprintf'
gettimeofday.c
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _vsnprintf already defined in libcrypto_static.lib(cryptlib.obj)
scrypt.obj : warning LNK4197: export 'init_scrypt' specified multiple times; using first specification
   Creating library build\temp.win-amd64-2.7\Release\src\_scrypt.lib and object build\temp.win-amd64-2.7\Release\src\_scrypt.exp
libcrypto_static.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vswprintf referenced in function OPENSSL_showfatal
libcrypto_static.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsprintf referenced in function OPENSSL_showfatal
build\lib.win-amd64-2.7\_scrypt.pyd : fatal error LNK1120: 2 unresolved externals
error: Setup script exited with error: command 'C:\\Users\\Never\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1120

我决定尝试下载Win64 OpenSSL v1.1.1bhg clone http://bitbucket.org/mhallin/py-scrypt编辑 setup.py 看起来像这样:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, Extension

import sys
import platform
import struct
import os

includes = []
libraries = []
library_dirs = []
extra_sources = []
CFLAGS = []


if sys.platform.startswith('linux'):
    define_macros = [('HAVE_CLOCK_GETTIME', '1'),
                     ('HAVE_LIBRT', '1'),
                     ('HAVE_POSIX_MEMALIGN', '1'),
                     ('HAVE_STRUCT_SYSINFO', '1'),
                     ('HAVE_STRUCT_SYSINFO_MEM_UNIT', '1'),
                     ('HAVE_STRUCT_SYSINFO_TOTALRAM', '1'),
                     ('HAVE_SYSINFO', '1'),
                     ('HAVE_SYS_SYSINFO_H', '1'),
                     ('_FILE_OFFSET_BITS', '64')]
    libraries = ['crypto', 'rt']
    includes = ['/usr/local/include', '/usr/include']
    CFLAGS.append('-O2')
elif sys.platform.startswith('win32'):
    define_macros = [('inline', '__inline')]

    extra_sources = ['scrypt-windows-stubs/gettimeofday.c']
    if struct.calcsize('P') == 8:
        library_dirs = ['c:\OpenSSL-Win64\lib']
        includes = ['c:\OpenSSL-Win64\include', 'scrypt-windows-stubs/include']
    else:
        library_dirs = ['c:\OpenSSL-Win32\lib']
        includes = ['c:\OpenSSL-Win32\include', 'scrypt-windows-stubs/include']
    windows_link_legacy_openssl = os.environ.get(
        "SCRYPT_WINDOWS_LINK_LEGACY_OPENSSL", None
    )
    if  windows_link_legacy_openssl is None:
        libraries = ['libcrypto_static']
    else:
        libraries = ['libeay32']
    libraries += ["advapi32", "gdi32", "user32", "ws2_32"]

elif sys.platform.startswith('darwin') and platform.mac_ver()[0] < '10.6':
    define_macros = [('HAVE_SYSCTL_HW_USERMEM', '1')]
    # disable for travis
    libraries = ['crypto']
elif sys.platform.startswith('darwin'):
    define_macros = [('HAVE_POSIX_MEMALIGN', '1'),
                     ('HAVE_SYSCTL_HW_USERMEM', '1')]
    # disable for travis
    libraries = ['crypto']
else:
    define_macros = [('HAVE_POSIX_MEMALIGN', '1'),
                     ('HAVE_SYSCTL_HW_USERMEM', '1')]
    libraries = ['crypto']

scrypt_module = Extension(
    '_scrypt',
    sources=['src/scrypt.c',
             'scrypt-1.2.1/lib/crypto/crypto_scrypt_smix_sse2.c',
             'scrypt-1.2.1/lib/crypto/crypto_scrypt_smix.c',
             'scrypt-1.2.1/lib/crypto/crypto_scrypt.c',
             'scrypt-1.2.1/lib/scryptenc/scryptenc.c',
             'scrypt-1.2.1/lib/scryptenc/scryptenc_cpuperf.c',
             'scrypt-1.2.1/lib/util/memlimit.c',
             'scrypt-1.2.1/libcperciva/alg/sha256.c',
             'scrypt-1.2.1/libcperciva/crypto/crypto_aes_aesni.c',
             'scrypt-1.2.1/libcperciva/crypto/crypto_aes.c',
             'scrypt-1.2.1/libcperciva/crypto/crypto_aesctr.c',
             'scrypt-1.2.1/libcperciva/crypto/crypto_entropy.c',
             'scrypt-1.2.1/libcperciva/util/entropy.c',
             'scrypt-1.2.1/libcperciva/util/insecure_memzero.c',
             'scrypt-1.2.1/libcperciva/util/warnp.c',
             'scrypt-1.2.1/libcperciva/util/humansize.c',
             'scrypt-1.2.1/libcperciva/util/asprintf.c'] + extra_sources,
    include_dirs=['scrypt-1.2.1',
                  'scrypt-1.2.1/lib',
                  'scrypt-1.2.1/lib/scryptenc',
                  'scrypt-1.2.1/lib/crypto',
                  'scrypt-1.2.1/lib/util',
                  'scrypt-1.2.1/libcperciva/cpusupport',
                  'scrypt-1.2.1/libcperciva/alg',
                  'scrypt-1.2.1/libcperciva/util',
                  'scrypt-1.2.1/libcperciva/crypto'] + includes,
    define_macros=[('HAVE_CONFIG_H', None)] + define_macros,
    extra_compile_args=CFLAGS,
    library_dirs=library_dirs,
    libraries=libraries)

setup(name='scrypt',
      version='0.8.13',
      description='Bindings for the scrypt key derivation function library',
      author='Magnus Hallin',
      author_email='mhallin@gmail.com',
      maintainer="Holger Nahrstaedt",
      maintainer_email="holger@nahrstaedt.de",
      url='http://bitbucket.org/mhallin/py-scrypt',
      packages=['scrypt'],
      ext_modules=[scrypt_module],
      classifiers=['Development Status :: 4 - Beta',
                   'Intended Audience :: Developers',
                   'License :: OSI Approved :: BSD License',
                   'Programming Language :: Python :: 2.7',
                   'Programming Language :: Python :: 3',
                   'Programming Language :: Python :: 3.4',
                   'Programming Language :: Python :: 3.5',
                   'Programming Language :: Python :: 3.6',
                   'Programming Language :: Python :: 3.7',
                   'Topic :: Security :: Cryptography',
                   'Topic :: Software Development :: Libraries'],
      license='2-clause BSD',
      long_description=open('README.rst').read(),
      test_suite='tests.all_tests')

不确定我是否做对了。我有一个很长的结果要在这里发布,但错误python setup.py build是:

libcrypto_static.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vswprintf referenced in function OPENSSL_showfatal
libcrypto_static.lib(cryptlib.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsprintf referenced in function OPENSSL_showfatal
build\lib.win-amd64-2.7\_scrypt.pyd : fatal error LNK1120: 2 unresolved externals
error: command 'C:\\Users\\Never\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1120

它默认了REEE的其他错误信息!“仅将此标头用于 Microsoft Visual C++ 编译器!” 当我“重新安装”disutils.cfg 时。这打击,我已经将所有这些库安装在一个大约 6 岁的系统上,它爆炸了,我刚刚得到了构建一个新的部件。我知道它可以安装,我只是不记得我是怎么把它拉下来的。

4

2 回答 2

0

我建议尝试python -m easy_install scrypt。过去,每当我遇到错误时failed with error code 1,我都会使用easy_install而不是pip,并且效果很好。

于 2019-02-27T23:59:59.207 回答
0

pip install scrypt==0.8.11:)

上面.11还会显示一堆这样的错误。

安装Win64OpenSSL-1_1_1c.msi..

当我为 ida 7 安装密钥补丁时,我收到了这样的错误

于 2019-07-05T22:49:00.407 回答