See this link before you really want to install pure Python by yourself instead of miniconda:
- Note: If
pyenv install <version>
connect to python.org time out- Visit this secret gist to setup proxies:
Hansimov/proxies.md
- Visit this secret gist to setup proxies:
Download pyenv-installer and run it:
wget https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer
bash pyenv-installer
Add following lines to ~/.bashrc
:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
Relauch the shell to make it work:
bash # Or exec "$SHELL"
Then run the commands:
# Install the latest Python from source code
pyenv install 3.9.6
pyenv versions
# Switch Python version
pyenv global 3.9.6
# Check where Python is actually installed
pyenv prefix
# > /home/admin/.pyenv/versions/3.9.6
# Check the current Python version
python -V
# > Python 3.9.6
References:
- installation - Unable to install Python without sudo access - Stack Overflow
- bash: pyenv: command not found and how to solve it · Issue #103 · pyenv/pyenv-installer
Visit following link to get latest Python
- https://registry.npmmirror.com/binary.html?path=python/
- Example: https://registry.npmmirror.com/-/binary/python/3.9.6/Python-3.9.6.tgz
Download the .tgz via Chrome browser and drag & drop to target path in server via MobaXterm.
tar -zxvf Python-3.9.6.tgz
# find ./Python-3.9.6/Python -type d | xargs chmod 0755
cd Python-3.11.3
./configure --prefix=$PWD/Python-3.9.6/Python
make
make install
mv ~/Python-3.9.6 ~/bin/
Add Python to path by adding this line to .bashrc:
export PATH=~/bin/Python-3.9.6:$PATH
or add alias to .bash_aliases
:
alias python="~/bin/Python-3.9.6/python"
Do not forget to relauch bash to make the path work:
bash
If create Python venv,
python -m venv ~/bin/pyvenv
remove the above export and alias for root python, replace with the following ones:
# .bashrc
export PATH=~/bin/pyvenv/bin:$PATH
export pv=~/bin/pyvenv
# .bash_aliases
alias python="~/bin/pyvenv/bin/python"
bash
Activate python venv:
source $pv/bin/activate
or use alias:
alias sv="source ~/bin/pyvenv/bin/activate"
See the following link for more setup:
- pip install connect timeout.md
References:
- How to install Python 3 on Linux without sudo access.
- venv — Creation of virtual environments — Python 3.11.3 documentation