non-root user install python3 for linux

Chentao Yang Lv4

直接用prefix指定自己的安装目录

1
2
3
4
5
6
7
# 非root 用户可以直接用以下命令安装
wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
tar -Jxvf Python-3.10.2.tar.xz
cd Python-3.10.2
./configure --prefix=/home/yourname/python
make
make install

按照上面的方法安装之后可能有个问题是,用pip安装模块的时候,不能使用ssl,这可能和你没有openssl有关,所以需要在安装python的时候,添加openssl的依赖关系.

1
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
1
2
3
4
5
6
7
8
./configure  --prefix=/home/yourname/python --with-openssl=/home/yourname/openssl_env
make
make install

# 添加环境变量
export LIBRARY_PATH="/home/yourname/openssl_env/lib:$LIBRARY_PATH"
export LD_LIBRARY_PATH="/home/yourname/openssl_env/lib:$LD_LIBRARY_PATH"

  • Title: non-root user install python3 for linux
  • Author: Chentao Yang
  • Created at : 2022-04-13 16:29:47
  • Updated at : 2023-10-25 11:56:14
  • Link: https://comery.github.io/2022/04/14/non-root-user-install-python3-for-linux/
  • License: This work is licensed under CC BY-NC-SA 4.0.
 Comments
On this page
non-root user install python3 for linux