Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing _socket after compile python 3.6

I've try compile python3.6 with:

emc@belvedere:~/py36/Python-3.6.0rc1> ./configure --prefix=/home/emc/py36 --with-system-expat --with-system-expat --with-system-ffi --disable-ipv6 && make && make install

Compilation is success I can start interpreter:

emc@belvedere:~/py36/bin> ./python3.6
Python 3.6.0rc1 (default, Dec 14 2016, 13:08:45) 
[GCC 4.8.1 20130909 [gcc-4_8-branch revision 202388]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

but:

emc@belvedere:~/py36/bin> pip3.6 
Traceback (most recent call last):
  File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
    from . import urllib3
  File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
    from .connectionpool import (
  File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 7, in <module>
    from socket import error as SocketError, timeout as SocketTimeout
  File "/home/emc/py36/lib/python3.6/socket.py", line 49, in <module>
    import _socket
ModuleNotFoundError: No module named '_socket'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/emc/py36/bin/pip3.6", line 7, in <module>
    from pip import main
  File "/home/emc/py36/lib/python3.6/site-packages/pip/__init__.py", line 21, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
    from .packages.urllib3.exceptions import DependencyWarning
  File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
    import urllib3
ModuleNotFoundError: No module named 'urllib3'

During configuration I didn't get any problems:
http://pastebin.com/ePQ1awas

In fact I can see some socket lib in:

/home/emc/py36/lib64/python3.6/lib-dynload/_socket.cpython-36m-x86_64-linux-gnu.so

EDIT:
Can't import socket (same for thread)

>>> import _socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named '_socket'
>>> 
>>> 
>>> import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/emc/py36/lib/python3.6/socket.py", line 49, in <module>
    import _socket
ModuleNotFoundError: No module named '_socket'
like image 644
emcek Avatar asked Dec 14 '16 15:12

emcek


2 Answers

Adding /home/emc/py36/lib/python3.6/site-packages to PYTHONPATH solved problem.

like image 76
emcek Avatar answered Nov 09 '22 12:11

emcek


I had a similar problem after building 3.7.4 with prefix=/usr/local

Fix was to add to .bashrc the two lines:

export PYTHONHOME=/usr/local
export PYTHONPATH=/usr/local/lib64/python3.7/lib-dynload
like image 3
John Avatar answered Nov 09 '22 12:11

John