繁体   English   中英

Package Python3.7不可用

[英]Package Python3.7 is not available

所以我有 python 3.8 和 pip ,但我想为它安装稳定的 python 3.7 和 Z62AD1C2C2A956C5298DDC33 。 但是当我尝试sudo apt-get install python3.7 ,它说 package 不可用,而是指另一个 package。 请帮助错误:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python3.7 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3.7' has no installation candidate

我尝试在 Kali Linux 的官方docker 图像中执行以下步骤。 它也应该在桌面上工作。

apt-get update
apt-get install -y build-essential openssl openssl-dev* wget curl
wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
tar -xvf Python-3.7.8.tgz
cd Python-3.7.8
./configure --enable-shared
make 
make test
make install

# Steps from here are to enable other libraries in linux to 
# access the shared python libraries.

cd /usr/local/lib/
cp libpython3.so /usr/lib64/
cp libpython3.so /usr/lib
cp libpython3.7m.so.1.0 /usr/lib64/
cp libpython3.7m.so.1.0 /usr/lib/
cd /usr/lib64
ln -s libpython3.7m.so.1.0 libpython3.7m.so
cd /usr/lib
ln -s libpython3.7m.so.1.0 libpython3.7m.so

完成,python3.7 安装完成。

root@fe794c7ff15e:~# python3
Python 3.7.8 (default, Aug 15 2020, 16:26:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

我尝试使用此安装创建 python 虚拟环境。 它工作正常。 我也能够安装 pip 软件包。

(testvirtual) root@fe794c7ff15e:~# pip install flask
Collecting flask
  Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
     |████████████████████████████████| 94 kB 404 kB/s 
Collecting Jinja2>=2.10.1
  Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 10.4 MB/s 
Collecting click>=5.1
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 165 kB/s 
Collecting Werkzeug>=0.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 11.9 MB/s 
Collecting itsdangerous>=0.24
  Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting MarkupSafe>=0.23
  Downloading MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl (27 kB)
Installing collected packages: MarkupSafe, Jinja2, click, Werkzeug, itsdangerous, flask
Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 flask-1.1.2 itsdangerous-1.1.0

现在 Ubuntu 中的默认 Python 版本是 3.8,这是按安装的。 虽然看起来像 2.x 版本的旧版本 spark 需要 Python 版本 3.7。 我遇到了同样的问题,我做了以下

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7

更新 bashrc 以将 PYSPARK_PYTHON 环境变量指向上面安装的 python3.7,如下所示

export PYSPARK_PYTHON=/usr/bin/python3.7
source ~/.bashrc

以下命令似乎有效,但请记住关于deadsnakes PPA的免责声明:

[T]如果出现安全问题或其他问题,我们不保证及时更新。 如果您想在安全或其他关键环境中使用它们(例如,在生产服务器上),您需要自担风险。

但是,如果你真的想这样做:

apt update
apt install python3 python3-pip software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt install python3.7

以下是我在开始新的 Python 项目时遵循的步骤:

首先,我决定发布 Python。 假设您想使用 Python 3.7.8。

要安装特定版本,我使用pyenv 它在gitbug上并使用这个脚本来安装它。

安装 pyenv 后,您应该cd到您的代码所在的位置并输入pyenv install 3.7.8pyenv local 3.7.8这将确保在该位置创建 Python 3.7.8 环境。

然后你安装诗歌curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python

安装诗歌后(使用poetry -V看是否有效),您可以运行poetry init以创建pyproject.toml文件。

您可以像这样添加新的依赖项: poetry add requests

你可以通过poetry shell进入那个环境。

现在,您在特定的 3.7.8 python 版本中使用您的新项目,并在单独的 shell 中使用您的依赖项。

这些东西都不适合我安装 python3.7

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM