CFFI在Python(Linux)虚拟环境中失败 - 尝试在venv中安装加密包

时间:2022-10-06 18:23:00

Installing cffi in the virtual environment encounters errors, but seems to install. Are these errors actually critical, ones that could lead it to fail when installing cryptography (see further below)?

在虚拟环境中安装cffi遇到错误,但似乎安装。这些错误是否真的很重要,可能会导致它在安装加密时失败(请参阅下文)?

pip install cffi==1.11.5

pip install cffi == 1.11.5

Downloading/unpacking cffi==1.11.5

Downloading cffi-1.11.5.tar.gz (438kB): 438kB downloaded
Running setup.py (path:/[venv-install-directory]/build/cffi/setup.py) egg_info for package cffi
Downloading/unpacking pycparser (from cffi==1.11.5)
Downloading pycparser-2.18.tar.gz (245kB): 245kB downloaded
Running setup.py (path:/[venv-install-directory]/build/pycparser/setup.py) egg_info for package pycparser
warning: no previously-included files matching 'yacctab.' found under directory 'tests'
warning: no previously-included files matching 'lextab.
' found under directory 'tests'
warning: no previously-included files matching 'yacctab.' found under directory 'examples'
warning: no previously-included files matching 'lextab.
' found under directory 'examples'
Installing collected packages: cffi, pycparser
Running setup.py install for cffi
building '_cffi_backend' extension
gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/local/lib/libffi-3.2.1/include -I/[venv-install-directory]/include -I/usr/local/include/python3.4m -c c/_cffi_backend.c -o build/temp.linux-i686-3.4/c/_cffi_backend.o
gcc -pthread -shared build/temp.linux-i686-3.4/c/_cffi_backend.o -L/usr/local/lib -lffi -o build/lib.linux-i686-3.4/_cffi_backend.cpython-34m.so Could not find .egg-info directory in install record for cffi==1.11.5
Running setup.py install for pycparser
warning: no previously-included files matching 'yacctab.' found under directory 'tests'
warning: no previously-included files matching 'lextab.
' found under directory 'tests'
warning: no previously-included files matching 'yacctab.' found under directory 'examples'
warning: no previously-included files matching 'lextab.
' found under directory 'examples'
Build the lexing/parsing tables
Could not find .egg-info directory in install record for pycparser (from cffi==1.11.5)
Successfully installed cffi pycparser
Cleaning up...

正在下载cffi-1.11.5.tar.gz(438kB):438kB已下载运行setup.py(路径:/ [venv-install-directory] ​​/build/cffi/setup.py)cop_info for package cffi正在下载/解压pycparser(来自: cffi == 1.11.5)下载pycparser-2.18.tar.gz(245kB):245kB已下载运行setup.py(路径:/ [venv-install-directory] ​​/build/pycparser/setup.py)egg_info for package pycparser warning :没有匹配'yacctab'的先前包含的文件。在目录'tests'警告下找到:没有先前包含的文件匹配'lextab'。在目录'tests'警告下找到:没有先前包含的文件匹配'yacctab'。在目录'examples'下找到警告:没有先前包含的文件匹配'lextab'。在目录'examples'下找到安装收集的软件包:cffi,pycparser为cffi构建'_cffi_backend'扩展运行setup.py安装gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I / usr / local / lib / libffi-3.2.1 / include -I / [venv-install-directory] ​​/ include -I / usr / local / include / python3.4m -cc / _cffi_backend.c -o build / temp.linux-i686-3.4 / c / _cffi_backend.o gcc -pthread -shared build / temp.linux-i686-3.4 / c / _cffi_backend.o -L / usr / local / lib -lffi -o build /lib.linux-i686-3.4/_cffi_backend.cpython-34m.so在cffi的安装记录中找不到.egg-info目录== 1.11.5运行pycparser警告的setup.py install:没有先前包含的文件匹配' yacctab“。在目录'tests'警告下找到:没有先前包含的文件匹配'lextab'。在目录'tests'警告下找到:没有先前包含的文件匹配'yacctab'。在目录'examples'下找到警告:没有先前包含的文件匹配'lextab'。在目录'examples'下找到构建lexing / parsing表在pycparser的安装记录中找不到.egg-info目录(来自cffi == 1.11.5)已成功安装cffi pycparser清理...

This problem is perplexing because it works on my local system, but when creating a virtual environment, the following error occurs during the attempted install of cryptography:

此问题令人困惑,因为它可以在我的本地系统上运行,但在创建虚拟环境时,在尝试安装加密期间会发生以下错误:

  File "[path-to-venv]/build/cryptography/src/_cffi_src/utils.py", line 57, in build_ffi
   ffi = FFI()

   File "[path-to-venv]/lib/python3.4/site-packages/cffi/api.py", line 46, in __init__
    import _cffi_backend as backend

ImportError: [path-to-venv]/lib/python3.4/site-packages/_cffi_backend.cpython-34m.so: undefined symbol: __syscall_error

A virtual environment literally creates a copy of the local environment, doesn't it?

虚拟环境从字面上创建了本地环境的副本,不是吗?

So how is "_cffi_backend" not working in the virtual environment, when there's no problem on the system install itself? I don't see how this could happen in the first place.

那么,当系统安装本身没有问题时,“_ cffi_backend”如何在虚拟环境中不起作用?我不知道这首先是怎么发生的。

Has anyone successfully dealt with a problem like this one? If you have ideas or a solution, please be specific since I've already spent quite a few hours trying solutions that haven't worked so far.

有没有人成功处理过像这样的问题?如果您有想法或解决方案,请具体说明,因为我已经花了几个小时尝试迄今为止尚未解决的解决方案。

Among other things, I've already tried compiling and installing libffi from source before creating the virtual environment: https://sourceware.org/libffi/

除此之外,我已经尝试在创建虚拟环境之前从源代码编译和安装libffi:https://sourceware.org/libffi/

Are there other alternatives for creating virtual environments that don't require re-installing every package -- i.e. where can just use your existing installed setup and copy it directly into the virtual environment (or a similar way that avoids falling into dependency hell)?

是否有其他替代方法可用于创建不需要重新安装每个软件包的虚拟环境 - 即可以使用现有的已安装设置并将其直接复制到虚拟环境中(或者避免陷入依赖性地狱的类似方式)?

This seems like a simple issue to solve once you have a grasp of the actual problem. If I can't figure this out, I can't deploy my project since it crucially depends on cryptography. So thanks in advance for any ideas you might have that could help fix this issue.

一旦掌握了实际问题,这似乎是一个简单的问题。如果我无法弄清楚这一点,我无法部署我的项目,因为它至关重要取决于加密。所以,提前感谢您可能有的任何想法可以帮助解决这个问题。

1 个解决方案

#1


0  

The answer in this case was to upgrade pip -- inside the virtual environment.

在这种情况下的答案是升级pip - 在虚拟环境中。

Complete instructions:

  1. create the virtual environment.

    创建虚拟环境。

    python3.4 -m venv [venv_name_here]

    python3.4 -m venv [venv_name_here]

  2. enter the virtual environment.

    进入虚拟环境。

    cd [venv_name_here]

  3. activate the virtual environment.

    激活虚拟环境。

    source bin/activate

4. upgrade pip.

4.升级点。

pip install --upgrade pip

pip install --upgrade pip

  1. install setuptools.

    pip install setuptools==39.1.0

    pip install setuptools == 39.1.0

  2. install pyparser.

    pip install pyparser==1.0
    pip install pyparsing==2.1.0

    pip install pyparser == 1.0 pip install pyparsing == 2.1.0

  3. install cffi.

    pip install cffi==1.11.5

    pip install cffi == 1.11.5

  4. install cryptography.

    pip install cryptography==2.2.2

    pip install cryptography == 2.2.2

Completes installation perfectly, with no errors.

完美安装,没有错误。

Note that you may need to change version numbers, depending on the output of the "pip freeze" command (i.e. look at your 'requirements.txt' file):

请注意,您可能需要更改版本号,具体取决于“pip freeze”命令的输出(即查看“requirements.txt”文件):

pip freeze -l > requirements.txt

pip freeze -l> requirements.txt

#1


0  

The answer in this case was to upgrade pip -- inside the virtual environment.

在这种情况下的答案是升级pip - 在虚拟环境中。

Complete instructions:

  1. create the virtual environment.

    创建虚拟环境。

    python3.4 -m venv [venv_name_here]

    python3.4 -m venv [venv_name_here]

  2. enter the virtual environment.

    进入虚拟环境。

    cd [venv_name_here]

  3. activate the virtual environment.

    激活虚拟环境。

    source bin/activate

4. upgrade pip.

4.升级点。

pip install --upgrade pip

pip install --upgrade pip

  1. install setuptools.

    pip install setuptools==39.1.0

    pip install setuptools == 39.1.0

  2. install pyparser.

    pip install pyparser==1.0
    pip install pyparsing==2.1.0

    pip install pyparser == 1.0 pip install pyparsing == 2.1.0

  3. install cffi.

    pip install cffi==1.11.5

    pip install cffi == 1.11.5

  4. install cryptography.

    pip install cryptography==2.2.2

    pip install cryptography == 2.2.2

Completes installation perfectly, with no errors.

完美安装,没有错误。

Note that you may need to change version numbers, depending on the output of the "pip freeze" command (i.e. look at your 'requirements.txt' file):

请注意,您可能需要更改版本号,具体取决于“pip freeze”命令的输出(即查看“requirements.txt”文件):

pip freeze -l > requirements.txt

pip freeze -l> requirements.txt