2017-05-19 71 views
0

我想在具有不同python版本的virtualenv環境中運行scrapyVirtualenv:使用python 3.5在virtualenv env中運行`Scrapy`給出錯誤

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. 
+0

不應該是'source。/ NAME/bin/activate'嗎? –

+0

@RemyJ它被激活。我做了'cd'來輸入它。我也應該寫。 –

+0

嘗試pip3安裝scrapy == 1.1.0rc1 –

回答

-1

嘗試PIP安裝scrapy

須藤PIP安裝scrapy

而當你寫python3打開哪個版本?

+0

爲什麼須藤?還有問題說,它安裝得很好 –

+0

我認爲這是安裝問題。怎麼樣python部分 – IsaBostan

+0

這是一個virtualenv,那麼它呢? –