簡體   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