简体   繁体   中英

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.

通过向PYTHONPATH变量添加更多路径来解决该问题

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/"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM