2014-06-21 49 views
7

Vì vậy, trong số nhiều gói người dùng cần cài đặt cho Scrapy, tôi nghĩ rằng tôi đang gặp sự cố với pyOpenSSL.Cài đặt gói phụ thuộc cho Scrapy

Khi tôi cố gắng để có được một dự án Scrapy hướng dẫn tạo ra, tôi có được điều này đầu ra sau đây:

Traceback (most recent call last): 
    File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main 
    "__main__", fname, loader, pkg_name) 
    File "C:\Python27\lib\runpy.py", line 72, in _run_code 
    exec code in run_globals 
    File "C:\Python27\lib\site-packages\scrapy\cmdline.py", line 168, in <module> 
    execute() 
    File "C:\Python27\lib\site-packages\scrapy\cmdline.py", line 122, in execute 
    cmds = _get_commands_dict(settings, inproject) 
    File "C:\Python27\lib\site-packages\scrapy\cmdline.py", line 46, in _get_comma 
nds_dict 
    cmds = _get_commands_from_module('scrapy.commands', inproject) 
    File "C:\Python27\lib\site-packages\scrapy\cmdline.py", line 29, in _get_comma 
nds_from_module 
    for cmd in _iter_command_classes(module): 
    File "C:\Python27\lib\site-packages\scrapy\cmdline.py", line 20, in _iter_comm 
and_classes 
    for module in walk_modules(module_name): 
    File "C:\Python27\lib\site-packages\scrapy\utils\misc.py", line 68, in walk_mo 
dules 
    submod = import_module(fullpath) 
    File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module 
    __import__(name) 
    File "C:\Python27\lib\site-packages\scrapy\commands\bench.py", line 3, in <mod 
ule> 
    from scrapy.tests.mockserver import MockServer 
    File "C:\Python27\lib\site-packages\scrapy\tests\mockserver.py", line 6, in <m 
odule> 
    from twisted.internet import reactor, defer, ssl 
    File "C:\Python27\lib\site-packages\twisted\internet\ssl.py", line 59, in <mod 
ule> 
    from OpenSSL import SSL 
    File "build\bdist.win32\egg\OpenSSL\__init__.py", line 8, in <module> 
    File "build\bdist.win32\egg\OpenSSL\rand.py", line 11, in <module> 
    File "build\bdist.win32\egg\OpenSSL\_util.py", line 3, in <module> 
ImportError: No module named cryptography.hazmat.bindings.openssl.binding 

Và khi tôi googled rằng lỗi cuối cùng (không có mô-đun tên cryptography.hazmat), tôi thấy một vài đề cập đến của pyOpenSSL. Vì vậy, tôi đã đi trước và cố gắng chạy easy_install pyOpenSSL==0.14 để chắc chắn rằng nó là phiên bản mới nhất, nhưng khi tôi làm điều đó, tôi nhận ra điều này:

c:\python27\include\pymath.h(22) : warning C4273: 'round' : inconsistent dll lin 
kage 
     C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(51 
6) : see previous definition of 'round' 
c:\users\bk\appdata\local\temp\easy_install-tztawu\cryptography-0.4\temp\easy_in 
stall-svxsjy\cffi-0.8.2\c\misc_win32.h(225) : error C2632: 'char' followed by 'b 
ool' is illegal 
c:\users\bk\appdata\local\temp\easy_install-tztawu\cryptography-0.4\temp\easy_in 
stall-svxsjy\cffi-0.8.2\c\misc_win32.h(225) : warning C4091: 'typedef ' : ignore 
d on left of 'unsigned char' when no variable is declared 
c/_cffi_backend.c(5295) : warning C4146: unary minus operator applied to unsigne 
d type, result still unsigned 
c/_cffi_backend.c(5296) : warning C4146: unary minus operator applied to unsigne 
d type, result still unsigned 
c/_cffi_backend.c(5297) : warning C4146: unary minus operator applied to unsigne 
d type, result still unsigned 
c/_cffi_backend.c(5298) : warning C4146: unary minus operator applied to unsigne 
d type, result still unsigned 
error: Setup script exited with error: command '"C:\Program Files (x86)\Microsof 
t Visual Studio 12.0\VC\BIN\cl.exe"' failed with exit status 2 

Vì vậy, tôi là một chút mất như những gì tôi cần phải làm để có được Phế liệu và chạy đúng cách

+0

Tôi có Python 32 bit được cài đặt cũng như pyopenssl 32 bit. Không chắc chắn những gì khác có thể là nhầm lẫn 64 bit ... – simplycoding

Trả lời

1

Tôi khuyên bạn nên sử dụng conda thay vì pip, đặc biệt khi sử dụng Windows. Trong số nhiều thứ khác, nó sẽ lấy các tệp nhị phân thích hợp cho hệ thống của bạn. Nó làm cho việc thiết lập một môi trường python khoa học (nghĩ rằng Scipy, Numpy, Pandas ...) thật dễ dàng.

Vì vậy, đọc lên trên Anaconda, cài đặt Anaconda, sau đó làm:

conda create -n scrapyenv python=2 # creates a new py2 environment 
activate scrapyenv     # switch to the new environment 
conda install scrapy    # install scrapy 

bước một và hai là chỉ cần thiết nếu bạn muốn nó gói gọn trong một môi trường riêng biệt. Btw, toàn bộ pin của các gói hữu ích sẽ được cài đặt nếu bạn thực hiện conda install anaconda.

Bổ sung, trong trường hợp conda không bao gồm pyOpenSSL hoặc bạn KHÔNG muốn cài đặt anaconda hãy xem điểm 9 của hướng dẫn How to install Scrapy in 64bit Windows 7.

+0

Tôi đã có cùng một vấn đề phụ thuộc và cài đặt lại với conda thay vì pip giải quyết, nhờ – mgilbert

21

Tôi gặp lỗi tương tự trên Mac OS.

Tôi đã giải quyết nó bằng cách sử dụng openssl 0.13 thay vì phiên bản mới nhất.

easy_install pyOpenSSL==0.13 

hoặc

pip install pyOpenSSL==0.13 
+0

Thumbs up cho nó làm việc .. Đây là năm 2015 trong lịch sử nhiều người thực hiện hầu hết các mọi thứ mà không biết tại sao nó hoạt động ... – nehemiah

+0

Sử dụng pip làm việc cho tôi, không cần phải chỉ định phiên bản mặc dù – TomSelleck

0

tôi có những vấn đề tương tự, và cố gắng giải quyết nó với câu trả lời đầu tiên, nhưng nó không hoạt động. Cuối cùng, tôi gỡ bỏ pyOpenSSL và tải xuống thiết lập pyopenssl. Và vấn đề được giải quyết. Url của pyopenssl là: https://launchpad.net/pyopenssl

0

Bạn nên nâng cấp pip trước khi bạn cố gắng để cài đặt Scrapy:

pip install --upgrade pip 
pip install Scrapy 
Các vấn đề liên quan