ModuleNotFoundError: No module named '_socket' after installing python3 to a local folder

I installed Python 3.7.4 from sources to a local folder. Installation did not produce any errors, but the binaries do not work.

That's what I did to install and setup the software

./configure --prefix=/usr/local/python3.7.4 make -j 8 install export PYTHONHOME="/usr/local/python3.7.4/" export PYTHONPATH="/usr/local/python3.7.4/lib/python3.7/site-packages/" 

That's what I get when attempt to run python3

/usr/local/python3.7.4/bin/python3 Python 3.7.4 (default, Sep 4 2019, 19:14:06) [GCC 4.8.3 20140627 [gcc-4_8-branch revision 212064]] on linux Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "/etc/pythonstart", line 7, in <module> import readline ModuleNotFoundError: No module named 'readline' 

and this is what I get from pip3:

/usr/local/python3.7.4/bin/pip3 Traceback (most recent call last): File "/usr/local/python3.7.4/bin/pip3", line 6, in <module> from pip._internal import main File "/usr/local/python3.7.4/lib/python3.7/site-packages/pip/_internal/__init__.py", line 19, in <module> from pip._vendor.urllib3.exceptions import DependencyWarning File "/usr/local/python3.7.4/lib/python3.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module> from .connectionpool import ( File "/usr/local/python3.7.4/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 7, in <module> from socket import error as SocketError, timeout as SocketTimeout File "/usr/local/python3.7.4/lib/python3.7/socket.py", line 49, in <module> import _socket ModuleNotFoundError: No module named '_socket' 

I feel that the core of the problem is the local installation.

I am sorry if my question is trivial. I tried googling it with no success.

Thank you for your time.

1 Answer

The problem was resolved by adding more paths to the PYTHONPATH variable

export PYTHONPATH="/usr/local/python3.7.4/lib/python3.7/site-packages/:/usr/local/python3.7.4/:/usr/local/python3.7.4/lib64/python3.7/lib-dynload/" 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like