简体   繁体   English

Package Python3.7不可用

[英]Package Python3.7 is not available

So I have python 3.8 and pip for it, but I want to install stable python 3.7 and pip for it also.所以我有 python 3.8 和 pip ,但我想为它安装稳定的 python 3.7 和 Z62AD1C2C2A956C5298DDC33 。 But when I try sudo apt-get install python3.7 It says package is not available but is referred to another package.但是当我尝试sudo apt-get install python3.7 ,它说 package 不可用,而是指另一个 package。 Help please Error:请帮助错误:

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

I tried doing the below steps in an official docker image of Kali Linux.我尝试在 Kali Linux 的官方docker 图像中执行以下步骤。 It should work on the desktop as well.它也应该在桌面上工作。

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

Done, python3.7 is installed.完成,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.
>>>

I tried creating a python virtual environment with this install.我尝试使用此安装创建 python 虚拟环境。 It worked properly.它工作正常。 I was able to install pip packages as well.我也能够安装 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

Default Python version in Ubuntu nowadays is 3.8 which is per-installed.现在 Ubuntu 中的默认 Python 版本是 3.8,这是按安装的。 While it looks like older version of spark like 2.x versions require Python version 3.7.虽然看起来像 2.x 版本的旧版本 spark 需要 Python 版本 3.7。 I ran into same issue and I did the below我遇到了同样的问题,我做了以下

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

Updated bashrc to point PYSPARK_PYTHON environment variable to python3.7 installed above like below更新 bashrc 以将 PYSPARK_PYTHON 环境变量指向上面安装的 python3.7,如下所示

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

The following commands seem to work, but bear in mind the disclaimer about the deadsnakes PPA :以下命令似乎有效,但请记住关于deadsnakes PPA的免责声明:

[T]here's no guarantee of timely updates in case of security problems or other issues. [T]如果出现安全问题或其他问题,我们不保证及时更新。 If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk.如果您想在安全或其他关键环境中使用它们(例如,在生产服务器上),您需要自担风险。

But, if you really want to do this:但是,如果你真的想这样做:

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

Here are the steps I follow when starting a new Python project:以下是我在开始新的 Python 项目时遵循的步骤:

First I decide on a Python release.首先,我决定发布 Python。 Let's say you want to work with Python 3.7.8.假设您想使用 Python 3.7.8。

To install a specific release, I use pyenv .要安装特定版本,我使用pyenv It's on gitbug and use this script to install it.它在gitbug上并使用这个脚本来安装它。

After installing pyenv you should cd to the place your code will be and enter pyenv install 3.7.8 and pyenv local 3.7.8 which will make sure that the Python 3.7.8 environment will be created at that location.安装 pyenv 后,您应该cd到您的代码所在的位置并输入pyenv install 3.7.8pyenv local 3.7.8这将确保在该位置创建 Python 3.7.8 环境。

Then you install poetry : 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 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

After poetry is installed (use poetry -V to see if it works), you can run poetry init to create a pyproject.toml file.安装诗歌后(使用poetry -V看是否有效),您可以运行poetry init以创建pyproject.toml文件。

You can add new dependencies like this: poetry add requests .您可以像这样添加新的依赖项: poetry add requests

And you can enter that environment via poetry shell .你可以通过poetry shell进入那个环境。

Now your using your new project in your specific 3.7.8 python version using your dependencies in a separate shell.现在,您在特定的 3.7.8 python 版本中使用您的新项目,并在单独的 shell 中使用您的依赖项。

None of these things worked for me to install python3.7这些东西都不适合我安装 python3.7

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

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