在 openSUSE 上安装最新的 Python
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18875165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing newest Python on openSUSE
提问by clstaudt
I installed Python on an openSUSE system (see version below) using the Zypper package manager. This gives me Python 3.2, but some packages require Python 3.3. Updating with zypper update python3
stays on Python 3.2. How can I upgrade to 3.3, ideally using the package manager and reusing the rest of my working Python installation (site packages, pip...)?
我使用 Zypper 包管理器在 openSUSE 系统(见下面的版本)上安装了 Python。这给了我 Python 3.2,但有些包需要 Python 3.3。更新zypper update python3
保持在 Python 3.2 上。如何升级到 3.3,理想情况下使用包管理器并重用我的其余工作 Python 安装(站点包、pip...)?
openSUSE 12.2 (x86_64)
VERSION = 12.2
CODENAME = Mantis
采纳答案by TobiMarg
You can add the devel:languages:python:Factoryrepository or use the 1 Click Installand a Python 3.3.2 version form here(e.g. from the above repo).
(Show other versions->openSUSE 12.2->Show unstable packages->1 Click Install)
您可以在此处添加devel:languages:python:Factory存储库或使用1 单击安装和 Python 3.3.2 版本表单(例如来自上述存储库)。
(显示其他版本->openSUSE 12.2->显示不稳定包->1点击安装)
To use it with zypperonly (no GUI) you can add the repo as follows:
要仅与zypper 一起使用(无 GUI),您可以按如下方式添加 repo:
sudo zypper ar http://download.opensuse.org/repositories/devel:/languages:/python:/Factory/openSUSE_12.2/devel:languages:python:Factory.repo
Then, to use packages from that repo you should give the repo a higher priority (in this case higher priority means lower number 0=high, 100=low). To know the repo id use zypper lr
and search for the repo number in the output. Then use the following command to change the priority:
然后,要使用该 repo 中的包,您应该给 repo 更高的优先级(在这种情况下,更高的优先级意味着较低的数字 0=high,100=low)。要知道 repo id 使用zypper lr
并在输出中搜索 repo 编号。然后使用以下命令更改优先级:
sudo zypper mr -p priority repo_number
You could use e.g. 50 as priority if your other repos have the standard priority of 99.
Then use zypper update python3
to update python.
如果您的其他存储库的标准优先级为 99,您可以使用例如 50 作为优先级。
然后用于zypper update python3
更新 python。
回答by Zouzias
You can follow the instructions below using pyenv:
您可以使用 pyenv 按照以下说明进行操作:
# Step 1. Install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
# Step 2. Install missing headers for all the Python modules to be built
sudo zypper install readline-devel sqlite3-devel libbz2-devel
# Step 3. Install the desired Python version
pyenv install 3.6.3
quoting from https://gist.github.com/antivanov/01ed4eac2d7486a170be598b5a0a4ac7
引自https://gist.github.com/antivanov/01ed4eac2d7486a170be598b5a0a4ac7