本站消息

站长简介/公众号


站长简介:高级软件工程师,曾在阿里云,每日优鲜从事全栈开发工作,利用周末时间开发出本站,欢迎关注我的微信公众号:程序员总部,程序员的家,探索程序员的人生之路!分享IT最新技术,关注行业最新动向,让你永不落伍。了解同行们的工资,生活工作中的酸甜苦辣,谋求程序员的最终出路!

  价值13000svip视频教程,python大神匠心打造,零基础python开发工程师视频教程全套,基础+进阶+项目实战,包含课件和源码

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

Virtualenv:使用python 3.5 在virtualenv env 中运行`Scrapy` 出现错误

发布于2022-01-08 19:29     阅读(1037)     评论(0)     点赞(30)     收藏(2)



我正在尝试scrapy在具有不同 python 版本的 virtualenv 环境中运行

对于python3,我做了以下事情:

virtualenv -p python3 NAME
cd NAME    
source /bin/activate

激活后,

pip3 install scrapy

它已成功安装。但是当我运行时scrapy,出现以下错误:

ImportError: /usr/local/lib/python2.7/dist-packages/cryptography/hazmat/bindings/_openssl.so: undefined symbol: PyInt_FromLong

这表明它正在使用我系统的python2.7.

我的最终目标是scrapy使用不同版本的python.

编辑:我认为cryptography模块有问题

当我尝试时 pip3 install --upgrade pyOpenSSL

我懂了 :

Collecting pyOpenSSL
  Using cached pyOpenSSL-17.0.0-py2.py3-none-any.whl
Collecting cryptography>=1.7 (from pyOpenSSL)
  Using cached cryptography-1.8.1.tar.gz
Requirement already up-to-date: six>=1.5.2 in ./lib/python3.5/site-packages (from pyOpenSSL)
Requirement already up-to-date: idna>=2.1 in ./lib/python3.5/site-packages (from cryptography>=1.7->pyOpenSSL)
Requirement already up-to-date: asn1crypto>=0.21.0 in ./lib/python3.5/site-packages (from cryptography>=1.7->pyOpenSSL)
Requirement already up-to-date: packaging in /usr/local/lib/python2.7/dist-packages (from cryptography>=1.7->pyOpenSSL)
Collecting setuptools>=11.3 (from cryptography>=1.7->pyOpenSSL)
  Using cached setuptools-35.0.2-py2.py3-none-any.whl
Collecting cffi>=1.4.1 (from cryptography>=1.7->pyOpenSSL)
  Using cached cffi-1.10.0-cp35-cp35m-manylinux1_x86_64.whl
Requirement already up-to-date: pyparsing in /usr/local/lib/python2.7/dist-packages (from packaging->cryptography>=1.7->pyOpenSSL)
Requirement already up-to-date: appdirs>=1.4.0 in /usr/local/lib/python2.7/dist-packages (from setuptools>=11.3->cryptography>=1.7->pyOpenSSL)
Requirement already up-to-date: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi>=1.4.1->cryptography>=1.7->pyOpenSSL)
Building wheels for collected packages: cryptography
  Running setup.py bdist_wheel for cryptography ... error
  Complete output from command /home/parth/gsoc/sample/try/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-nvvy22iz/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/tmp66xa7d7xpip-wheel- --python-tag cp35:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-nvvy22iz/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-nvvy22iz/cryptography/src/_cffi_src/utils.py", line 61, in build_ffi_for_binding
      extra_link_args=extra_link_args,
    File "/tmp/pip-build-nvvy22iz/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/gsoc/sample/try/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-nvvy22iz/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-nvvy22iz/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-nvvy22iz/cryptography/src/_cffi_src/utils.py", line 61, in build_ffi_for_binding
      extra_link_args=extra_link_args,
    File "/tmp/pip-build-nvvy22iz/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: setuptools, cffi, cryptography, pyOpenSSL
  Found existing installation: setuptools 34.3.2
    Not uninstalling setuptools at /usr/local/lib/python2.7/dist-packages, outside environment /home/parth/gsoc/sample/try
  Found existing installation: cffi 1.9.1
    Not uninstalling cffi at /usr/local/lib/python2.7/dist-packages, outside environment /home/parth/gsoc/sample/try
  Found existing installation: cryptography 1.5.3
    Not uninstalling cryptography at /usr/local/lib/python2.7/dist-packages, outside environment /home/parth/gsoc/sample/try
  Running setup.py install for cryptography ... error
    Complete output from command /home/parth/gsoc/sample/try/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-nvvy22iz/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-tdsypb26-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/parth/gsoc/sample/try/include/site/python3.5/cryptography:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-nvvy22iz/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-nvvy22iz/cryptography/src/_cffi_src/utils.py", line 61, in build_ffi_for_binding
        extra_link_args=extra_link_args,
      File "/tmp/pip-build-nvvy22iz/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

    ----------------------------------------
  Can't rollback cryptography, nothing uninstalled.

解决方案


试试

pip安装scrapy

或者

须藤pip安装scrapy

而当你写python3时打开哪个版本?







所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/1227329/4f459095205909db9028/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

30 0
收藏该文
已收藏

评论内容:(最多支持255个字符)