简体   繁体   English

Linux:无需安装即可运行 Python

[英]Linux: Run Python without installation

My company server install Redhat 6 with Python 2.6 default.我公司的服务器默认安装了 Python 2.6 的 Redhat 6。 The customer send me some sample code using Python 3.4 but I have not permission to install Python 3.4客户给我发送了一些使用 Python 3.4 的示例代码,但我没有安装 Python 3.4 的权限

Using Java, I can copy the jdk installation folder from another Linux server to mine without install it.使用 Java,我可以将 jdk 安装文件夹从另一个 Linux 服务器复制到我的,而无需安装它。 The only change I need to do is to change you JAVA_HOME and PATH variable accordingly我需要做的唯一改变是相应地改变你的 JAVA_HOME 和 PATH 变量

How can I apply this way for Python?如何将这种方式应用于 Python?

Go to python.org and download its source code, such as "Python-3.4.6.tar.xz", then extract it, change your directory to the root and run this script:转到python.org并下载其源代码,例如“Python-3.4.6.tar.xz”,然后将其解压缩,将目录更改为根目录并运行此脚本:

./configure; make

Here is also a shell script, and you could run it.这里还有一个 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

Finally, you could run python by ./python command.最后,您可以通过./python命令运行 python。

Here is output:这是输出:

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.
>>> 

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

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