2016-07-28 6 views
1

Ich versuche, verdreht zu installieren https://pypi.python.org/packages/18/85/eb7af503356e933061bf1220033c3a85bad0dbc5035dfd9a97f1e900dfcb/Twisted-16.2.0.tar.bz2#md5=8b35a88d5f1a4bfd762a008968fddabftarfile compressionerror bz2-Modul ist nicht verfügbar

Dies ist für ein django-channels Projekt installieren PIP- und ich bin mit dem folgenden Fehler Problem

Exception: 
Traceback (most recent call last): 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/tarfile.py", line 1655, in bz2open 
    import bz2 
    File "/usr/local/lib/python3.5/bz2.py", line 22, 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 "/home/petarp/.virtualenvs/CloneFromGitHub/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main 
    status = self.run(options, args) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/commands/install.py", line 310, in run 
    wb.build(autobuilding=True) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/wheel.py", line 750, in build 
    self.requirement_set.prepare_files(self.finder) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/req/req_set.py", line 370, in prepare_files 
    ignore_dependencies=self.ignore_dependencies)) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/req/req_set.py", line 587, in _prepare_file 
    session=self.session, hashes=hashes) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/download.py", line 810, in unpack_url 
    hashes=hashes 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/download.py", line 653, in unpack_http_url 
    unpack_file(from_path, location, content_type, link) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/utils/__init__.py", line 605, in unpack_file 
    untar_file(filename, location) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/utils/__init__.py", line 538, in untar_file 
    tar = tarfile.open(filename, mode) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/tarfile.py", line 1580, in open 
    return func(name, filemode, fileobj, **kwargs) 
    File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/tarfile.py", line 1657, in bz2open 
    raise CompressionError("bz2 module is not available") 
tarfile.CompressionError: bz2 module is not available 

Klar ich m fehlt bz2 Modul, also habe ich versucht, es manuell zu installieren, aber das hat nicht funktioniert für python 3.5, also wie kann ich das lösen?

Ich habe habe, was @ e4c5 vorgeschlagen, aber ich habe es für python3.5.1, ist der Ausgang

➜ ~ python3.5        
Python 3.5.1 (default, Apr 19 2016, 22:45:11) 
[GCC 4.8.4] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import bz2 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python3.5/bz2.py", line 22, in <module> 
    from _bz2 import BZ2Compressor, BZ2Decompressor 
ImportError: No module named '_bz2' 
>>> 
[3] + 18945 suspended python3.5 
➜ ~ dpkg -S /usr/local/lib/python3.5/bz2.py 
dpkg-query: no path found matching pattern /usr/local/lib/python3.5/bz2.py 

Ich bin auf 14.04 LTS Ubuntu und ich habe Python 3.5 von der Quelle installiert.

+0

Wie haben Sie versucht, es manuell zu installieren und was damit gemeint ist, hat nicht geklappt? – e4c5

+0

vielleicht habe ich es nicht gut ausgedrückt, indem ich manuell meine, dass ich es installiert habe mit 'sudo apt-get install libbz2-dev', aber das hat es nicht installiert für' python3.5', ich habe immer noch Dieses Modul fehlt, wenn ich es in der Python-Shell – PetarP

Antwort

1

Ich habe kein Problem mit import bz2 auf meiner Python 3.4 Installation. Also habe ich

import bz2 
print (bz2.__file__) 

Und festgestellt, dass es bei /usr/lib/python3.4/bz2.py gelegen ist dann habe ich

dpkg -S /usr/lib/python3.4/bz2.py 

Dies zeigt:

libpython3.4-stdlib: amd64:/usr/lib/python3 .4/bz2.py

Also sollte der folgende Befehl hoffentlich das beheben:

apt-get install libpython3.4-stdlib 

Update:

Wenn Sie Python 3.5 aus Quellen zusammengestellt haben, ist es sehr wahrscheinlich, dass der bz2 nicht in zusammengestellt Bitte neu installieren, indem zuerst

./configure --with-libs='bzip' 

das gleiche zu tun. gilt auch für Python 3.6. Beachten Sie, dass sich dies wahrscheinlich über andere fehlende Abhängigkeiten beklagen wird. Sie müssen die fehlenden Abhängigkeiten eins nach dem anderen installieren, bis alles abgedeckt ist.

+0

importieren Ich habe meine Frage bearbeitet, ich habe immer noch ein Problem mit 'Python 3.5', und ja, das funktioniert für Version 3.4, und ich habe' bz2' darauf – PetarP

+0

was ist dein Version von Ubuntu (oder entsprechende Ubuntu-Version für Ihre Distribution) – e4c5

+0

Ich benutze Ubuntu 14.04 tls – PetarP