iT邦幫忙

0

我已經搜尋了一些資料 有關 ubuntu 18安裝 python3

如下


$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install libssl-dev openssl libreadline-dev
$ cd ~
$ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
$ tar zxf Python-3.6.1.tgz
$ cd Python-3.6.1
$ ./configure
$ make
$ sudo make install

但是到import telepot 出現問題

peter@dvr:~$ python3 --version
Python 3.6.1
peter@dvr:~$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
peter@dvr:~$ python3
Python 3.6.1 (default, Dec 27 2019, 10:01:53)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import telepot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/.local/lib/python3.6/site-packages/telepot/__init__.py", line 346, in <module>
    from . import api
  File "/home/peter/.local/lib/python3.6/site-packages/telepot/api.py", line 1, in <module>
    import urllib3
  File "/home/peter/.local/lib/python3.6/site-packages/urllib3/__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "/home/peter/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 39, in <module>
    from .response import HTTPResponse
  File "/home/peter/.local/lib/python3.6/site-packages/urllib3/response.py", line 3, in <module>
    import zlib
ModuleNotFoundError: No module named 'zlib'
>>>

謝謝

froce iT邦大師 3 級 ‧ 2019-12-27 21:29:44 檢舉
重新編譯。
./configure --with-zlib

另外要在linux上用不同的版本,推薦用pyenv。
echochio iT邦研究生 1 級 ‧ 2020-01-02 21:58:37 檢舉
樓上正解

尚未有邦友回答

立即登入回答