在 Ubuntu 虚拟环境中安装 scrypt-0.7.1 时出现问题

在 Ubuntu 虚拟环境中安装 scrypt-0.7.1 时出现问题

我正在尝试安装 python 包加密进入我在 Ubuntu 下的虚拟 Python 环境。我不太明白错误消息。我该怎么做才能让它工作?

nuc@nuc:~/Dropbox/julie$ source julie/bin/activate
(julie)nuc@nuc:~/Dropbox/Julie$ pip install scrypt
Collecting scrypt
/home/nuc/Dropbox/Julie/julie/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading scrypt-0.7.1.tar.gz
Installing collected packages: scrypt
  Running setup.py install for scrypt
    Complete output from command /home/nuc/Dropbox/Julie/julie/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-utQ19_/scrypt/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-0_M4Md-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/nuc/Dropbox/Julie/julie/include/site/python2.7/scrypt:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying scrypt.py -> build/lib.linux-x86_64-2.7
    running build_ext
    building '_scrypt' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    creating build/temp.linux-x86_64-2.7/scrypt-1.1.6
    creating build/temp.linux-x86_64-2.7/scrypt-1.1.6/lib
    creating build/temp.linux-x86_64-2.7/scrypt-1.1.6/lib/crypto
    creating build/temp.linux-x86_64-2.7/scrypt-1.1.6/lib/scryptenc
    creating build/temp.linux-x86_64-2.7/scrypt-1.1.6/lib/util
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_CONFIG_H -DHAVE_CLOCK_GETTIME=1 -DHAVE_LIBRT=1 -DHAVE_POSIX_MEMALIGN=1 -DHAVE_STRUCT_SYSINFO=1 -DHAVE_STRUCT_SYSINFO_MEM_UNIT=1 -DHAVE_STRUCT_SYSINFO_TOTALRAM=1 -DHAVE_SYSINFO=1 -DHAVE_SYS_SYSINFO_H=1 -D_FILE_OFFSET_BITS=64 -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 -I/home/nuc/anaconda/include/python2.7 -c src/scrypt.c -o build/temp.linux-x86_64-2.7/src/scrypt.o -O2
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_CONFIG_H -DHAVE_CLOCK_GETTIME=1 -DHAVE_LIBRT=1 -DHAVE_POSIX_MEMALIGN=1 -DHAVE_STRUCT_SYSINFO=1 -DHAVE_STRUCT_SYSINFO_MEM_UNIT=1 -DHAVE_STRUCT_SYSINFO_TOTALRAM=1 -DHAVE_SYSINFO=1 -DHAVE_SYS_SYSINFO_H=1 -D_FILE_OFFSET_BITS=64 -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 -I/home/nuc/anaconda/include/python2.7 -c scrypt-1.1.6/lib/crypto/crypto_aesctr.c -o build/temp.linux-x86_64-2.7/scrypt-1.1.6/lib/crypto/crypto_aesctr.o -O2
    scrypt-1.1.6/lib/crypto/crypto_aesctr.c:38:25: fatal error: openssl/aes.h: Datei oder Verzeichnis nicht gefunden
     #include <openssl/aes.h>
                         ^
compilation terminated.
error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/home/nuc/Dropbox/Julie/julie/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-utQ19_/scrypt/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-0_M4Md-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/nuc/Dropbox/julie/julie/include/site/python2.7/scrypt" failed with error code 1 in /tmp/pip-build-utQ19_/scrypt

答案1

两个错误消息,两个答案:

  1. 只需运行以下命令即可安装 ssl 开发库

    sudo apt-get install libssl-dev
    

    为什么?

    从错误信息来看:

    scrypt-1.1.6/lib/crypto/crypto_aesctr.c:38:25: fatal error: openssl/aes.h: Datei oder Verzeichnis nicht gefunden
    #include <openssl/aes.h>
    

    哪里openssl/aes.h

    % apt-file search openssl/aes.h
    libssl-dev: /usr/include/openssl/aes.h
    
  2. 另一个错误信息

    /home/nuc/Dropbox/Julie/julie/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
      InsecurePlatformWarning
    

    使用此命令

    conda install cryptography
    pip install 'requests[security]'
    

    或者使用 Python > 2.7.9

相关内容