Linux: 运行 Python 没有安装

Linux: Run Python without installation

我公司的服务器默认安装 Python 2.6 的 Redhat 6。客户使用 Python 3.4 向我发送了一些示例代码,但我无权安装 Python 3.4

使用Java,我可以将jdk安装文件夹从另一个Linux服务器复制到我的服务器上,而无需安装。我需要做的唯一改变就是相应地改变你 JAVA_HOME 和 PATH 变量

Python如何申请这种方式?

转到python.org并下载其源代码,例如"Python-3.4.6.tar.xz",然后解压缩,将目录更改为根目录和运行此脚本:

./configure; make

这里还有一个 shell 脚本,你可以 运行 它。

# get-python3.sh
wget https://www.python.org/ftp/python/3.4.6/Python-3.4.6.tar.xz
tar xvfJ Python-3.4.6.tar.xz
cd Python-3.4.6
./configure
make

最后,您可以 运行 python 通过 ./python 命令。

这是输出:

Python 3.4.6 (default, Mar 20 2017, 20:03:28) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>