Home > Enterprise >  install python3 and pip3 without sudo right
install python3 and pip3 without sudo right

Time:01-02

I tried to install python3 on a linux server without the admin right. I searched around as found something like

tar zxfv Python-3.11.tgz
find ~/python -type d | xargs chmod 0755
cd Python-3.11
./configure --prefix=$HOME/python --with-ssl=/usr/lib/ssl
make && make install

The installation was successful. But when I run the pip3 to install packages, it returns the error of SSL

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

The orignial python on the server can connect to pypi.org. I thought it may be some path error when the python3.11 was instlled without sudo right.

Any sugggestions? Thanks!

tried configured the ssl path as mentioned above, but not working.

./configure --prefix=$HOME/python --with-ssl=/usr/lib/ssl

CodePudding user response:

Your build is missing the ssl module, because of an incorrect configure option provided:

--with-ssl

The correct configure option is:

--with-openssl

The path should be to the dir containing include/openssl/ssl.h, i.e. if you have

/path/to/openssl-1.1.1g/include/openssl/ssl.h

Then provide:

--with-openssl=/path/to/openssl-1.1.1g/

You'll see in the output of ./configure whether ssl.h is found or not. Don't bother to run make until the ./configure is correctly finding OpenSSL headers, otherwise you'll just end up with a broken build and no _ssl extension module available.

CodePudding user response:

Try creating a virtual environment.

python3 -m venv 'whatever you want to name your virtual environment'

then you can pip install and your packages should be installed locally within the virtual environment

  • Related