struggle tweets to install python 3.10.2 with pyenv on Ubuntu 20.04 (WSL)

If you want to watch me struggle, continue below. Otherwise just go here: https://computingforgeeks.com/how-to-install-python-on-ubuntu-linux-system/

I just bought a new laptop and figured, setting up my WSL Ubuntu environment should be pretty straightforward right? All I need to do is git clone a few repos and setup my $PATH.

I was very wrong.

I’m not an expert in setting up Linux environments and it just so happened that Stackoverflow was going through some things (https://twitter.com/StackStatus/status/1502788125285879817).

Anyway, some of the things I needed to get my pyenv v2.2.4 to even install python v3.10.2

At this point I’ve already apt install the following:

gcc
make
build-essential
gcc
make
build-essential
gcc make build-essential

Enter fullscreen mode Exit fullscreen mode

but I’m still getting the following error:

<span>$ </span>pyenv <span>install </span>3.10.2
Downloading Python-3.10.2.tar.xz...
-> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
Installing Python-3.10.2...
BUILD FAILED <span>(</span>Ubuntu 20.04 using python-build 2.2.4<span>)</span>
Inspect or clean up the working tree at /tmp/python-build.20220312160907.27360
Results logged to /tmp/python-build.20220312160907.27360.log
Last 10 log lines:
File <span>"/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py"</span>, line 277, <span>in </span>_main
<span>return </span>_bootstrap<span>(</span>
File <span>"/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py"</span>, line 193, <span>in </span>_bootstrap
<span>return </span>_run_pip<span>([</span><span>*</span>args, <span>*</span>_PACKAGE_NAMES], additional_paths<span>)</span>
File <span>"/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py"</span>, line 93, <span>in </span>_run_pip
<span>return </span>subprocess.run<span>([</span>sys.executable, <span>'-W'</span>, <span>'ignore::DeprecationWarning'</span>,
File <span>"/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/subprocess.py"</span>, line 524, <span>in </span>run
raise CalledProcessError<span>(</span>retcode, process.args,
subprocess.CalledProcessError: Command <span>'['</span>/tmp/python-build.20220312160907.27360/Python-3.10.2/python<span>', '</span><span>-W</span><span>', '</span>ignore::DeprecationWarning<span>', '</span><span>-c</span><span>', '</span><span>\n</span>import runpy<span>\n</span>import sys<span>\n</span>sys.path <span>=</span> <span>[</span><span>\'</span>/tmp/tmpbfu6lr32/setuptools-58.1.0-py3-none-any.whl<span>\'</span>, <span>\'</span>/tmp/tmpbfu6lr32/pip-21.2.4-py3-none-any.whl<span>\'</span><span>]</span> + sys.path<span>\n</span>sys.argv[1:] <span>=</span> <span>[</span><span>\'</span><span>install</span><span>\'</span>, <span>\'</span><span>--no-cache-dir</span><span>\'</span>, <span>\'</span><span>--no-index</span><span>\'</span>, <span>\'</span><span>--find-links</span><span>\'</span>, <span>\'</span>/tmp/tmpbfu6lr32<span>\'</span>, <span>\'</span><span>--root</span><span>\'</span>, <span>\'</span>/<span>\'</span>, <span>\'</span><span>--upgrade</span><span>\'</span>, <span>\'</span>setuptools<span>\'</span>, <span>\'</span>pip<span>\'</span><span>]</span><span>\n</span>runpy.run_module<span>(</span><span>"pip"</span>, <span>run_name</span><span>=</span><span>"__main__"</span>, <span>alter_sys</span><span>=</span>True<span>)</span><span>\n</span><span>']'</span> returned non-zero <span>exit </span>status 1.
make: <span>***</span> <span>[</span>Makefile:1280: <span>install</span><span>]</span> Error 1
<span>$ </span>pyenv <span>install </span>3.10.2
Downloading Python-3.10.2.tar.xz...
-> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
Installing Python-3.10.2...

BUILD FAILED <span>(</span>Ubuntu 20.04 using python-build 2.2.4<span>)</span>

Inspect or clean up the working tree at /tmp/python-build.20220312160907.27360
Results logged to /tmp/python-build.20220312160907.27360.log

Last 10 log lines:
  File <span>"/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py"</span>, line 277, <span>in </span>_main
    <span>return </span>_bootstrap<span>(</span>
  File <span>"/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py"</span>, line 193, <span>in </span>_bootstrap
    <span>return </span>_run_pip<span>([</span><span>*</span>args, <span>*</span>_PACKAGE_NAMES], additional_paths<span>)</span>
  File <span>"/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py"</span>, line 93, <span>in </span>_run_pip
    <span>return </span>subprocess.run<span>([</span>sys.executable, <span>'-W'</span>, <span>'ignore::DeprecationWarning'</span>,
  File <span>"/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/subprocess.py"</span>, line 524, <span>in </span>run
    raise CalledProcessError<span>(</span>retcode, process.args,
subprocess.CalledProcessError: Command <span>'['</span>/tmp/python-build.20220312160907.27360/Python-3.10.2/python<span>', '</span><span>-W</span><span>', '</span>ignore::DeprecationWarning<span>', '</span><span>-c</span><span>', '</span><span>\n</span>import runpy<span>\n</span>import sys<span>\n</span>sys.path <span>=</span> <span>[</span><span>\'</span>/tmp/tmpbfu6lr32/setuptools-58.1.0-py3-none-any.whl<span>\'</span>, <span>\'</span>/tmp/tmpbfu6lr32/pip-21.2.4-py3-none-any.whl<span>\'</span><span>]</span> + sys.path<span>\n</span>sys.argv[1:] <span>=</span> <span>[</span><span>\'</span><span>install</span><span>\'</span>, <span>\'</span><span>--no-cache-dir</span><span>\'</span>, <span>\'</span><span>--no-index</span><span>\'</span>, <span>\'</span><span>--find-links</span><span>\'</span>, <span>\'</span>/tmp/tmpbfu6lr32<span>\'</span>, <span>\'</span><span>--root</span><span>\'</span>, <span>\'</span>/<span>\'</span>, <span>\'</span><span>--upgrade</span><span>\'</span>, <span>\'</span>setuptools<span>\'</span>, <span>\'</span>pip<span>\'</span><span>]</span><span>\n</span>runpy.run_module<span>(</span><span>"pip"</span>, <span>run_name</span><span>=</span><span>"__main__"</span>, <span>alter_sys</span><span>=</span>True<span>)</span><span>\n</span><span>']'</span> returned non-zero <span>exit </span>status 1.
make: <span>***</span> <span>[</span>Makefile:1280: <span>install</span><span>]</span> Error 1
$ pyenv install 3.10.2 Downloading Python-3.10.2.tar.xz... -> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz Installing Python-3.10.2... BUILD FAILED (Ubuntu 20.04 using python-build 2.2.4) Inspect or clean up the working tree at /tmp/python-build.20220312160907.27360 Results logged to /tmp/python-build.20220312160907.27360.log Last 10 log lines: File "/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py", line 277, in _main return _bootstrap( File "/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py", line 193, in _bootstrap return _run_pip([*args, *_PACKAGE_NAMES], additional_paths) File "/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/ensurepip/__init__.py", line 93, in _run_pip return subprocess.run([sys.executable, '-W', 'ignore::DeprecationWarning', File "/tmp/python-build.20220312160907.27360/Python-3.10.2/Lib/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/tmp/python-build.20220312160907.27360/Python-3.10.2/python', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmpbfu6lr32/setuptools-58.1.0-py3-none-any.whl\', \'/tmp/tmpbfu6lr32/pip-21.2.4-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpbfu6lr32\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1. make: *** [Makefile:1280: install] Error 1

Enter fullscreen mode Exit fullscreen mode

Looking at the logs provided, indeed I am missing a lott of tools:

<span>$ </span><span>cat</span> /tmp/python-build.20220312160907.27360.log | <span>grep</span> <span>-e</span> <span>"hecking.*no$"</span> | <span>wc</span> <span>-l</span>
197
<span>$ </span><span>cat</span> /tmp/python-build.20220312160907.27360.log | <span>grep</span> <span>-e</span> <span>"hecking.*no$"</span> | <span>wc</span> <span>-l</span>
197
$ cat /tmp/python-build.20220312160907.27360.log | grep -e "hecking.*no$" | wc -l 197

Enter fullscreen mode Exit fullscreen mode

I’m just looking blindly through and find the following:

ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 618, in _get_data
File "<frozen zipimport>", line 573, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available
ModuleNotFoundError: No module named 'zlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen zipimport>", line 618, in _get_data
  File "<frozen zipimport>", line 573, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available
ModuleNotFoundError: No module named 'zlib' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<frozen zipimport>", line 618, in _get_data File "<frozen zipimport>", line 573, in _get_decompress_func zipimport.ZipImportError: can't decompress data; zlib not available

Enter fullscreen mode Exit fullscreen mode

The necessary bits to build these optional modules were not found:
_bz2 _curses _curses_panel
_dbm _gdbm _hashlib
_lzma _sqlite3 _ssl
_tkinter _uuid readline
zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc pwd time
Failed to build these modules:
_ctypes
Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel
_dbm                  _gdbm                 _hashlib
_lzma                 _sqlite3              _ssl
_tkinter              _uuid                 readline
zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time


Failed to build these modules:
_ctypes


Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer
The necessary bits to build these optional modules were not found: _bz2 _curses _curses_panel _dbm _gdbm _hashlib _lzma _sqlite3 _ssl _tkinter _uuid readline zlib To find the necessary bits, look in setup.py in detect_modules() for the module's name. The following modules found by detect_modules() in setup.py, have been built by the Makefile instead, as configured by the Setup files: _abc pwd time Failed to build these modules: _ctypes Could not build the ssl module! Python requires a OpenSSL 1.1.1 or newer

Enter fullscreen mode Exit fullscreen mode

okay, what is zlib? https://packages.ubuntu.com/source/focal/zlib

Not too helpful, as there are a bunch of different packages here that I can install, but which one?

The internet seems to say zlib1g-dev.

So I suppose I’ll need to get the dev versions of all these C library packages:

zlib1g-dev
libbz2-dev
libsqlite3-dev
libgdbm-dev
libssl-dev
libncurses5-dev
libreadline-dev
liblzma-dev
zlib1g-dev
libbz2-dev
libsqlite3-dev
libgdbm-dev
libssl-dev
libncurses5-dev
libreadline-dev
liblzma-dev
zlib1g-dev libbz2-dev libsqlite3-dev libgdbm-dev libssl-dev libncurses5-dev libreadline-dev liblzma-dev

Enter fullscreen mode Exit fullscreen mode

Anyway, since I know nothing and am just meandering through this on my own even though I can copy paste the list of dependencies someone else has posted on the internet, I decide to only install zlib1g-dev since the other ones are required for optional modules (which I’ll probably need later and regret not installing now).

Okay so what happens when I try to pyenv install 3.10.2 now?

<span>$ </span>pyenv <span>install </span>3.10.2
Downloading Python-3.10.2.tar.xz...
-> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
Installing Python-3.10.2...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems
BUILD FAILED <span>(</span>Ubuntu 20.04 using python-build 2.2.4<span>)</span>
Inspect or clean up the working tree at /tmp/python-build.20220312165507.7502
Results logged to /tmp/python-build.20220312165507.7502.log
Last 10 log lines:
Installing collected packages: setuptools, pip
WARNING: Value <span>for </span>scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /home/banana/.pyenv/versions/3.10.2/include/python3.10/setuptools
sysconfig: /tmp/python-build.20220312165507.7502/Python-3.10.2/Include/setuptools
WARNING: Value <span>for </span>scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /home/banana/.pyenv/versions/3.10.2/include/python3.10/pip
sysconfig: /tmp/python-build.20220312165507.7502/Python-3.10.2/Include/pip
WARNING: The scripts pip3 and pip3.10 are installed <span>in</span> <span>'/home/banana/.pyenv/versions/3.10.2/bin'</span> which is not on PATH.
Consider adding this directory to PATH or, <span>if </span>you prefer to suppress this warning, use <span>--no-warn-script-location</span><span>.</span>
Successfully installed pip-21.2.4 setuptools-58.1.0
<span>$ </span>pyenv <span>install </span>3.10.2
Downloading Python-3.10.2.tar.xz...
-> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
Installing Python-3.10.2...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED <span>(</span>Ubuntu 20.04 using python-build 2.2.4<span>)</span>

Inspect or clean up the working tree at /tmp/python-build.20220312165507.7502
Results logged to /tmp/python-build.20220312165507.7502.log

Last 10 log lines:
Installing collected packages: setuptools, pip
  WARNING: Value <span>for </span>scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /home/banana/.pyenv/versions/3.10.2/include/python3.10/setuptools
  sysconfig: /tmp/python-build.20220312165507.7502/Python-3.10.2/Include/setuptools
  WARNING: Value <span>for </span>scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /home/banana/.pyenv/versions/3.10.2/include/python3.10/pip
  sysconfig: /tmp/python-build.20220312165507.7502/Python-3.10.2/Include/pip
  WARNING: The scripts pip3 and pip3.10 are installed <span>in</span> <span>'/home/banana/.pyenv/versions/3.10.2/bin'</span> which is not on PATH.
  Consider adding this directory to PATH or, <span>if </span>you prefer to suppress this warning, use <span>--no-warn-script-location</span><span>.</span>
Successfully installed pip-21.2.4 setuptools-58.1.0
$ pyenv install 3.10.2 Downloading Python-3.10.2.tar.xz... -> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz Installing Python-3.10.2... WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib? WARNING: The Python readline extension was not compiled. Missing the GNU readline lib? ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib? Please consult to the Wiki page to fix the problem. https://github.com/pyenv/pyenv/wiki/Common-build-problems BUILD FAILED (Ubuntu 20.04 using python-build 2.2.4) Inspect or clean up the working tree at /tmp/python-build.20220312165507.7502 Results logged to /tmp/python-build.20220312165507.7502.log Last 10 log lines: Installing collected packages: setuptools, pip WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/banana/.pyenv/versions/3.10.2/include/python3.10/setuptools sysconfig: /tmp/python-build.20220312165507.7502/Python-3.10.2/Include/setuptools WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/banana/.pyenv/versions/3.10.2/include/python3.10/pip sysconfig: /tmp/python-build.20220312165507.7502/Python-3.10.2/Include/pip WARNING: The scripts pip3 and pip3.10 are installed in '/home/banana/.pyenv/versions/3.10.2/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed pip-21.2.4 setuptools-58.1.0

Enter fullscreen mode Exit fullscreen mode

Okay that seems like a more positive step. The only error that I see now is that ssl extensions was not compiled. Seems important. Let’s install libssl-dev

Okay AGAIN:

Downloading Python-3.10.2.tar.xz...
-> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
Installing Python-3.10.2...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Installed Python-3.10.2 to /home/banana/.pyenv/versions/3.10.2
Downloading Python-3.10.2.tar.xz...
-> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
Installing Python-3.10.2...

WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Installed Python-3.10.2 to /home/banana/.pyenv/versions/3.10.2
Downloading Python-3.10.2.tar.xz... -> https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz Installing Python-3.10.2... WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib? WARNING: The Python readline extension was not compiled. Missing the GNU readline lib? WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib? Installed Python-3.10.2 to /home/banana/.pyenv/versions/3.10.2

Enter fullscreen mode Exit fullscreen mode

YAY!

$ pyenv versions
* system (set by /home/banana/.pyenv/version)
3.10.2
$ pyenv versions
* system (set by /home/banana/.pyenv/version)
  3.10.2
$ pyenv versions * system (set by /home/banana/.pyenv/version) 3.10.2

Enter fullscreen mode Exit fullscreen mode

We’ll ignore all the warnings… until next time.

原文链接:struggle tweets to install python 3.10.2 with pyenv on Ubuntu 20.04 (WSL)

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
Believe you can and you’re halfway there.
相信自己,你也就成功了一半
评论 抢沙发

请登录后发表评论

    暂无评论内容