2016-09-07 60 views
0

我有一個用python 3編寫的Scrapy蜘蛛,我想在我的雲Linux服務器上運行它作爲cron作業(我有根訪問權限) 首先,我不能使用pip3 install scrapy安裝,我面對:如何在雲linux上安裝和cron python3 Scrapy

Exception: 
Traceback (most recent call last): 
    File "/usr/local/lib/python3.4/tarfile.py", line 1642, in bz2open 
    import bz2 
    File "/usr/local/lib/python3.4/bz2.py", line 20, in <module> 
    from _bz2 import BZ2Compressor, BZ2Decompressor 
ImportError: No module named '_bz2' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/usr/local/lib/python3.4/site-packages/pip/basecommand.py", line 122, in main 
    status = self.run(options, args) 
    File "/usr/local/lib/python3.4/site-packages/pip/commands/install.py", line 278, in run 
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) 
    File "/usr/local/lib/python3.4/site-packages/pip/req.py", line 1197, in prepare_files 
    do_download, 
    File "/usr/local/lib/python3.4/site-packages/pip/req.py", line 1375, in unpack_url 
    self.session, 
    File "/usr/local/lib/python3.4/site-packages/pip/download.py", line 582, in unpack_http_url 
    unpack_file(temp_location, location, content_type, link) 
    File "/usr/local/lib/python3.4/site-packages/pip/util.py", line 625, in unpack_file 
    untar_file(filename, location) 
    File "/usr/local/lib/python3.4/site-packages/pip/util.py", line 543, in untar_file 
    tar = tarfile.open(filename, mode) 
    File "/usr/local/lib/python3.4/tarfile.py", line 1567, in open 
    return func(name, filemode, fileobj, **kwargs) 
    File "/usr/local/lib/python3.4/tarfile.py", line 1644, in bz2open 
    raise CompressionError("bz2 module is not available") 
tarfile.CompressionError: bz2 module is not available 

那我怎麼才能運行它作爲一個cron作業?

+0

爲什麼人們不讀錯誤信息?它清楚地說明了爲什麼失敗:'ImportError:沒有名爲'_bz2'的模塊 – Dawid

+0

[ImportError:Python 2.7.2中沒有名爲bz2的模塊]的可能重複(http://stackoverflow.com/questions/8115280/importerror-no -module-named-bz2-for-python-2-7-2) –

+0

[tarfile compressionerror bz2模塊的可能的重複不可用](https://stackoverflow.com/questions/38646400/tarfile-compressionerror-bz2-module -is - 不提供) – e4c5

回答

-1

看起來好像您沒有在您的雲服務器上安裝bzip模塊。這很可能與缺少bzip2庫缺失有關。

爲了安裝它,您可以鍵入:

apt-get install bzip2 

您可能需要前綴sudo該命令。

誠實地說,它應該是「開箱即用」的,因爲這是Python的主要優勢之一。希望這有助於!