我已在服务器上安装了debian 10。
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
ID=debian
arch: x86_64
它安装了python版本3.7.3,因此我尝试将其更新到版本3.8.5,并且我想使用checkinstall。 我将backports回购添加到sources.list中并安装checkinstall:
# install checkinstall
sudo apt install checkinstall
sudo apt update
然后我得到了python:
# download python in tar.xz
cd /opt
curl -O https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
tar -xf Python-3.8.5.tar.xz
cd Python-3.8.5
但是当我尝试这个
./configure --enable-optimizations
make
# Use the -n flag on make for your target and pipe to shell script
make -n altinstall > altinstall_script.sh
# run checkinstall with that shell script
chmod +x altinstall_script.sh
# and install
sudo checkinstall ./altinstall_script.sh --install
我收到错误消息:
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_dbm
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 atexit pwd
time
running build_scripts
copying and adjusting /opt/Python-3.8.5/Tools/scripts/pydoc3 -> build/scripts-3.8
copying and adjusting /opt/Python-3.8.5/Tools/scripts/idle3 -> build/scripts-3.8
copying and adjusting /opt/Python-3.8.5/Tools/scripts/2to3 -> build/scripts-3.8
changing mode of build/scripts-3.8/pydoc3 from 644 to 755
changing mode of build/scripts-3.8/idle3 from 644 to 755
changing mode of build/scripts-3.8/2to3 from 644 to 755
renaming build/scripts-3.8/pydoc3 to build/scripts-3.8/pydoc3.8
renaming build/scripts-3.8/idle3 to build/scripts-3.8/idle3.8
renaming build/scripts-3.8/2to3 to build/scripts-3.8/2to3-3.8
running install_lib
copying build/lib.linux-x86_64-3.8/_multibytecodec.cpython-38-x86_64-linux-gnu.so -> /usr/local/lib/python3.8/lib-dynload
error: [Errno 2] No such file or directory
rm: cannot remove '/usr/local/lib/python3.8/lib-dynload/_sysconfigdata__linux_x86_64-linux-gnu.py': No such file or directory
rm: cannot remove '/usr/local/lib/python3.8/lib-dynload/__pycache__': No such file or directory
Creating directory /usr/local/share/man/man1
Looking in links: /tmp/tmpaf3jv392
Processing /tmp/tmpaf3jv392/setuptools-47.1.0-py3-none-any.whl
Processing /tmp/tmpaf3jv392/pip-20.1.1-py2.py3-none-any.whl
Installing collected packages: setuptools, pip
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory
C
答案 0 :(得分:1)
我认为您在列出要安装的版本以查看本指南以获取更多信息时出错– https://linuxize.com/post/how-to-install-python-3-8-on-debian-10/
$ python3.8 --version
添加这段代码应该会有所帮助。
答案 1 :(得分:1)
这似乎对我有用:安装pyenv并将其用于安装python3.8.5。
我运行了以下命令:
# Install pyenv
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
# Load pyenv automatically by adding the following to ~/.bashrc:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# Check versions
pyenv install --list | grep " 3\.[678]"
# install python 3.8.5
pyenv install -v 3.8.5
# set python 3.8.5
pyenv global 3.8.5
# Now I can use python2 and python3
python2 -V # -> Python 2.7.16
python3 -V # -> Python 3.8.5
python -V # -> Python 3.8.5
pip -V # -> pip 20.1.1 from /root/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pip (python 3.8)
pip2 -V # -> pip 20.2.1 from /root/.local/lib/python2.7/site-packages/pip (python 2.7)
pip3 -V # -> pip 20.1.1 from /root/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pip (python 3.8)
# or return to system python
pyenv global system
# and then
python2 -V # -> Python 2.7.16
python -V # -> Python 2.7.16
python3 -V # -> Python 3.8.5
# and versions
pyenv versions
也许,您还需要安装依赖项:
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev