无法在virtualenv中安装Cryptography

时间:2017-05-20 08:31:27

标签: python python-3.x virtualenv

我已经检查了其他答案,但我无法做到。

我首先使用virtualenv创建pipenv --three,然后执行pipenv shell来激活它。

然后我做pip install cryptography安装它,但得到了以下日志:

Collecting cryptography
  Using cached cryptography-1.8.1.tar.gz
Requirement already satisfied: idna>=2.1 in /home/parth/.local/share/virtualenvs/parth/lib/python3.5/site-packages (from cryptography)
Requirement already satisfied: asn1crypto>=0.21.0 in /home/parth/.local/share/virtualenvs/parth/lib/python3.5/site-packages (from cryptography)
Requirement already satisfied: packaging in /usr/local/lib/python2.7/dist-packages (from cryptography)
Requirement already satisfied: six>=1.4.1 in /home/parth/.local/share/virtualenvs/parth/lib/python3.5/site-packages (from cryptography)
Requirement already satisfied: setuptools>=11.3 in /usr/local/lib/python2.7/dist-packages (from cryptography)
Requirement already satisfied: cffi>=1.4.1 in /usr/local/lib/python2.7/dist-packages (from cryptography)
Requirement already satisfied: pyparsing in /usr/local/lib/python2.7/dist-packages (from packaging->cryptography)
Requirement already satisfied: appdirs>=1.4.0 in /usr/local/lib/python2.7/dist-packages (from setuptools>=11.3->cryptography)
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi>=1.4.1->cryptography)
Building wheels for collected packages: cryptography
  Running setup.py bdist_wheel for cryptography ... error
  Complete output from command /home/parth/.local/share/virtualenvs/parth/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7294fe75/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp3iwtgsr_pip-wheel- --python-tag cp35:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-7294fe75/cryptography/setup.py", line 335, in <module>
      **keywords_with_side_effects(sys.argv)
    File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
      _setup_distribution = dist = klass(attrs)
    File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 320, in __init__
      _Distribution.__init__(self, attrs)
    File "/usr/lib/python3.5/distutils/dist.py", line 281, in __init__
      self.finalize_options()
    File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 387, in finalize_options
      ep.load()(self, ep.name, value)
    File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 187, in cffi_modules
      add_cffi_module(dist, cffi_module)
    File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
      execfile(build_file_name, mod_vars)
    File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 25, in execfile
      exec(code, glob, glob)
    File "src/_cffi_src/build_openssl.py", line 94, in <module>
      extra_link_args=extra_link_args(compiler_type()),
    File "/tmp/pip-build-7294fe75/cryptography/src/_cffi_src/utils.py", line 61, in build_ffi_for_binding
      extra_link_args=extra_link_args,
    File "/tmp/pip-build-7294fe75/cryptography/src/_cffi_src/utils.py", line 69, in build_ffi
      ffi = FFI()
    File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 56, in __init__
      import _cffi_backend as backend
  ImportError: /usr/local/lib/python2.7/dist-packages/_cffi_backend.so: undefined symbol: _Py_ZeroStruct

  ----------------------------------------
  Failed building wheel for cryptography
  Running setup.py clean for cryptography
  Complete output from command /home/parth/.local/share/virtualenvs/parth/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7294fe75/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-7294fe75/cryptography/setup.py", line 335, in <module>
      **keywords_with_side_effects(sys.argv)
    File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
      _setup_distribution = dist = klass(attrs)
    File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 320, in __init__
      _Distribution.__init__(self, attrs)
    File "/usr/lib/python3.5/distutils/dist.py", line 281, in __init__
      self.finalize_options()
    File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 387, in finalize_options
      ep.load()(self, ep.name, value)
    File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 187, in cffi_modules
      add_cffi_module(dist, cffi_module)
    File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
      execfile(build_file_name, mod_vars)
    File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 25, in execfile
      exec(code, glob, glob)
    File "src/_cffi_src/build_openssl.py", line 94, in <module>
      extra_link_args=extra_link_args(compiler_type()),
    File "/tmp/pip-build-7294fe75/cryptography/src/_cffi_src/utils.py", line 61, in build_ffi_for_binding
      extra_link_args=extra_link_args,
    File "/tmp/pip-build-7294fe75/cryptography/src/_cffi_src/utils.py", line 69, in build_ffi
      ffi = FFI()
    File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 56, in __init__
      import _cffi_backend as backend
  ImportError: /usr/local/lib/python2.7/dist-packages/_cffi_backend.so: undefined symbol: _Py_ZeroStruct

  ----------------------------------------
  Failed cleaning build dir for cryptography
Failed to build cryptography
Installing collected packages: cryptography
  Running setup.py install for cryptography ... error
    Complete output from command /home/parth/.local/share/virtualenvs/parth/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7294fe75/cryptography/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-e2obpe52-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/parth/.local/share/virtualenvs/parth/include/site/python3.5/cryptography:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-7294fe75/cryptography/setup.py", line 335, in <module>
        **keywords_with_side_effects(sys.argv)
      File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 320, in __init__
        _Distribution.__init__(self, attrs)
      File "/usr/lib/python3.5/distutils/dist.py", line 281, in __init__
        self.finalize_options()
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 387, in finalize_options
        ep.load()(self, ep.name, value)
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 187, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 25, in execfile
        exec(code, glob, glob)
      File "src/_cffi_src/build_openssl.py", line 94, in <module>
        extra_link_args=extra_link_args(compiler_type()),
      File "/tmp/pip-build-7294fe75/cryptography/src/_cffi_src/utils.py", line 61, in build_ffi_for_binding
        extra_link_args=extra_link_args,
      File "/tmp/pip-build-7294fe75/cryptography/src/_cffi_src/utils.py", line 69, in build_ffi
        ffi = FFI()
      File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 56, in __init__
        import _cffi_backend as backend
    ImportError: /usr/local/lib/python2.7/dist-packages/_cffi_backend.so: undefined symbol: _Py_ZeroStruct

    ----------------------------------------

由于某种原因,它正在使用

/usr/local/lib/python2.7/dist-packages/_cffi_backend.so

,即我系统的python2.7个软件包。我试过sudo apt-get install build-essential libssl-dev libffi-dev python-dev,但错误仍然存​​在。

0 个答案:

没有答案