javapythonlinuxinstallationportable-executable

Linux: Run Python without installation


My company server install Redhat 6 with Python 2.6 default. The customer send me some sample code using Python 3.4 but I have not permission to install Python 3.4

Using Java, I can copy the jdk installation folder from another Linux server to mine without install it. The only change I need to do is to change you JAVA_HOME and PATH variable accordingly

How can I apply this way for Python?


Solution

  • 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:

    ./configure; make
    

    Here is also a shell script, and you could run it.

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

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