尝试在我的Ubuntu 15.10服务器上运行需要Python 3.5的程序时,导入时出错:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/response.py", line 3, in <module>
import zlib
ImportError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bot.py", line 12, in <module>
import discord
File "/usr/local/lib/python3.5/dist-packages/discord/__init__.py", line 21, in <module>
from .client import Client
File "/usr/local/lib/python3.5/dist-packages/discord/client.py", line 43, in <module>
import requests
File "/usr/local/lib/python3.5/dist-packages/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/local/lib/python3.5/dist-packages/requests/utils.py", line 26, in <module>
from .compat import parse_http_list as _parse_list_header
File "/usr/local/lib/python3.5/dist-packages/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/usr/local/lib/python3.5/dist-packages/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/usr/local/lib/python3.5/dist-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.5/dist-packages/urllib3/response.py", line 3, in <module>
import zlib
ImportError: No module named 'zlib'
程序本身仅适用于3.5,否则我将使用3.4。 Anywho,当试图使用3.4时,没有问题。安装了包含zlib的软件包,它们可以与python3.4一起使用。
这可能是一个配置问题,但如果有人可以对此有所启发,我真的很感激。
修改
ii libpython3.5-minimal:amd64 3.5.0-3
amd64 Minimal subset of the Python language (version 3.5)
ii libpython3.5-stdlib:amd64 3.5.0-3
amd64 Interactive high-level object-oriented language (standard library, version 3.5)
ii python3.5 3.5.0-3
amd64 Interactive high-level object-oriented language (version 3.5)
ii python3.5-minimal 3.5.0-3
amd64 Minimal subset of the Python language (version 3.5)
编辑2
ii zlib1g:amd64 1:1.2.8.dfsg-2ubuntu4 amd64 compression library - runtime
ii zlib1g-dev:amd64 1:1.2.8.dfsg-2ubuntu4 amd64 compression library - development