{"id":25736924,"url":"https://github.com/phdenzel/local-python-install","last_synced_at":"2026-03-02T12:43:41.622Z","repository":{"id":146779637,"uuid":"94759674","full_name":"phdenzel/local-python-install","owner":"phdenzel","description":"How to install python on a server without sudo rights","archived":false,"fork":false,"pushed_at":"2019-06-04T13:36:19.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-26T06:34:58.337Z","etag":null,"topics":["how-to","tutorial"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phdenzel.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-19T09:27:36.000Z","updated_at":"2019-06-04T13:36:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"b7ce208c-bead-4f59-bb55-aa6403e54dc1","html_url":"https://github.com/phdenzel/local-python-install","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phdenzel/local-python-install","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phdenzel%2Flocal-python-install","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phdenzel%2Flocal-python-install/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phdenzel%2Flocal-python-install/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phdenzel%2Flocal-python-install/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phdenzel","download_url":"https://codeload.github.com/phdenzel/local-python-install/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phdenzel%2Flocal-python-install/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285431210,"owners_count":27170452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-20T02:00:05.334Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["how-to","tutorial"],"created_at":"2025-02-26T06:31:45.070Z","updated_at":"2025-11-20T12:03:24.969Z","avatar_url":"https://github.com/phdenzel.png","language":null,"readme":"#+TITLE: How to locally install python\n#+AUTHOR: phdenzel\n\n  On a server or shared machine, you might want to install stuff locally, i.e. in your home directory.\n  I often get asked how I installed python this way.\n  This is what I did (more or less):\n\n*** Installing in ~/local/python\n    First, we need to create the directories, where python has to be installed.\n    #+BEGIN_SRC shell\n      mkdir -p ~/local/python/2.7\n    #+END_SRC\n    \n    Then go to the created directories and download the python source code\n    (I used 2.7.something, however if you're starting out completely new, I recommend 3.6.5).\n    #+BEGIN_SRC shell\n      cd ~/local/python\n      wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz\n    #+END_SRC\n    \n    Unpack it... do you remember the tar flags?\n    #+BEGIN_SRC shell\n      tar zxfv Python-2.7.15.tgz\n    #+END_SRC\n\n    Make the directories safe from outside influence\n    #+BEGIN_SRC shell\n      find ~/local/python -type d | xargs chmod 0755\n    #+END_SRC\n    \n    ... and finally install in your local directory with\n    #+BEGIN_SRC shell\n      cd Python-2.7.15\n      ./configure --prefix=$HOME/local/python/2.7\n      make \u0026\u0026 make install\n    #+END_SRC\n    Make sure to include the ~--prefix~ flag, since this is where the output of ~make~ is installed.\n    On UNIX machines this is by default in ~/usr/local~.\n    \n    If you've received an error message about the C compiler, you might have to change the second line to\n    #+BEGIN_SRC shell\n      CC=gcc ./configure --prefix=$HOME/local/python/2.7\n    #+END_SRC\n    or a similar compiler of your choice (that works).\n\n    On macOS (if you decide to install ~python~ from source code) many dependencies are very outdated!\n    That's why if you installed another Tcl/Tk version (~8.6~) for example you can specify additional flags\n\n    #+BEGIN_SRC shell\n      ./configure --prefix=$HOME/local/python/2.7 \\\n                  --with-tcltk-includes='-I/Library/Frameworks/Tcl.framework/Headers -I/Library/Frameworks/Tk.framework/Headers' \\\n                  --with-tcltk-libs='/Library/Frameworks/Tcl.framework/Versions/8.6/Tcl /Library/Frameworks/Tk.framework/Versions/8.6/Tk'\n      make \u0026\u0026 make install\n    #+END_SRC\n\n    If you want to build a framework-based python on macOS use\n    #+BEGIN_SRC shell\n      ./configure --prefix=$HOME/local/python/2.7 \\\n                  --enable-framework=$HOME/local/python/2.7 \\\n                  --with-tcltk-includes='-I/Library/Frameworks/Tcl.framework/Headers -I/Library/Frameworks/Tk.framework/Headers' \\\n                  --with-tcltk-libs='/Library/Frameworks/Tcl.framework/Versions/8.6/Tcl /Library/Frameworks/Tk.framework/Versions/8.6/Tk'\n      make \u0026\u0026 make install\n    #+END_SRC\n\n    On linux, Tcl can easily be installed with ~sudo apt-get install tcl8.6 tcl8.6-dev libtcl8.6 tk8.6 tk8.6-dev libtk8.6~.\n    The additional flags then are\n    \n    #+BEGIN_SRC shell\n      ./configure --prefix=$HOME/local/python/2.7 \\\n                  --with-tcltk-includes='-I/usr/include/tcl8.6 -I/usr/include/tk8.6' \\\n                  --with-tcltk-libs='/usr/lib/*-linux-gnu/libtcl8.6.so /usr/lib/*-linux-gnu/libtk8.6.so'\n      make \u0026\u0026 make install\n    #+END_SRC\n\n    On some linux machines, it can happen that ~lib-dynload~ is installed in a non-default location.\n    To easily fix this, I found that the following command usually helps\n\n    #+BEGIN_SRC shell\n      cp -r $HOME/local/python/2.7/lib64/python2.7/lib-dynload $HOME/local/python/2.7/lib/python2.7/\n    #+END_SRC\n\n*** Defining path variables\n\n    Now that we have locally installed python, we have to define the path to the local library in our ~.bash_profile~.\n    #+BEGIN_SRC shell\n      export PATH=$HOME/local/python/2.7/bin:$PATH\n      export PYTHONPATH=$HOME/local/python/2.7\n    #+END_SRC\n    \n    To test if it worked type\n    #+BEGIN_SRC shell\n      source ~/.bash_profile\n      which python\n    #+END_SRC\n    or something similar (like ~.bashrc~).\n    If the output of ~which~ includes ~/local/python/~ it worked!\n\n\n*** Setting up pip\n\n    I use pip to install all my python libraries.\n\n    Since python is already installed, it is relatively painless to install ~pip~.\n    #+BEGIN_SRC shell :export\n    wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py -O - | python - --user\n    #+END_SRC\n    \n    This downloads and installs ~pip~ locally in ~$HOME/.local/bin~.\n    If you installed python as a framework, the above ~pip~ install command will automatically \n    install ~pip~ in ~$HOME/Library/Python/2.7/~.\n    However, if you want to install it still in ~$HOME/.local/~ use\n    #+BEGIN_SRC shell :export\n    wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py -O - | python - --prefix=$HOME/.local/\n    #+END_SRC\n\n    Now, we just have to update the PATH in your ~.bash_profile~ and you're good to go...\n    #+BEGIN_SRC shell\n      export PATH=$HOME/.local/bin:$PATH\n    #+END_SRC\n    \n    Again, test it with\n    #+BEGIN_SRC shell\n      source ~/.bash_profile\n      which pip\n    #+END_SRC\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphdenzel%2Flocal-python-install","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphdenzel%2Flocal-python-install","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphdenzel%2Flocal-python-install/lists"}