Python3.6 Upgrade - problems with PIP, _socket, urllib3

Hey guys,

I built Python3.6 from source in Leap 42.2 with make altinstall next to version 3.4. I adjusted PYTHONHOME and PYTHONPATH as follows:


**➜  ****~** echo $PYTHONHOME $PYTHONPATH
/usr/lib/python3.6:/usr/lib64/python3.6 /usr/lib/python3.6:/usr/lib/python3.6/site-packages:/usr/lib64/python3.6/lib-dynload

I was able to install several site-packages like pandas via:


**➜  ****~** sudo python3.6 -m pip install pandas 

pip3.6 itself shows off errors.


**➜  ****~** sudo pip3.6 install pandas
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>:<exec_prefix>]
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
    from . import urllib3
  File "/usr/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
    from .connectionpool import (
  File "/usr/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 "/usr/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 "/usr/bin/pip3.6", line 7, in <module>
    from pip import main
  File "/usr/lib/python3.6/site-packages/pip/__init__.py", line 21, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
    from .packages.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
    import urllib3
ModuleNotFoundError: No module named 'urllib3'


Do you have an idea what I can do? Especially I need to install keras, tensorflow, pyqt5 and all of them are usable neither with pip nor with pip3.6. If I start python3.6 via terminal and import _socket it works fine.

Thanks in advance!
Reiti

Hi
So why not install the 3.6 build for Leap 42.2 from the Factory repo?
https://build.opensuse.org/project/show/devel:languages:python:Factory

http://download.opensuse.org/repositories/devel:/languages:/python:/Factory/openSUSE_Leap_42.2/

First,
I agree with Malcolm that you should install your Python from openSUSE when necessary.

I’d also recommend

  • Install and use virtualenv to run versions of Python side by side on your system (You can then easily specify your chosen Python version for any directory tree). Last I checked, openSUSE Python systems are built with integrated virtualenv (pre-configured).
  • If you choose not to install Python from openSUSE, your next best option is to install Python from the Python repositories (using pip which you’re already doing for individual apps). Building from source should be your last option when other options aren’t available.

That said,
Your errors are describing dependencies which can’t be found…
They might be a result of missing or improper system paths, code which wasn’t built or built properly or misconfiguration. Hard to tell exact cause without investigation but all of this can be avoided by installing pre-compiled Python.

HTH,
TSU