Python3.6 ImportError: cannot import name 'main' Linux RHEL6

My ultimate goal is to download and install awscli http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-linux.html

It seems like python and pip are needed to achieve my goal.

Installing python via yum does not work for me, so I downloaded and installed python3 manually as follows:

wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xf Python-3.6.1.tar.xz
cd Python-3.6.1.tar.xz
./configure
make
sudo make altinstall

When i do

pip3.6 --version

I get this:

Traceback (most recent call last):
  File "/usr/local/bin/pip3.6", line 7, in <module>
    from pip import main
ImportError: cannot import name 'main'

Environment: RHEL 6.6 Access via ssh

What's happening? How to install pip and python3.6 correctly in my Linux window?

Edit:

When trying to install via yum, this fails, so I try to avoid using yum:

[asemani@rcdc9pfda5r Python-3.6.1]$ sudo yum -y install python-pip

[sudo] password for asemeani: 
Loaded plugins: security
Setting up Install Process
No package python-pip available.
Error: Nothing to do

Other Edit:

After importing sys and then calling sys.path this is what I get:

[asemani@rcdc9pfda5r Python-3.6.1]$ python3.6
Python 3.6.1 (default, Apr 28 2017, 11:03:27) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages']
>>> quit()
[asemani@rcdc9pfda5r Python-3.6.1]$ ls -l /usr/local/lib/python3.6/site-packages
total 32
-rw-------  1 root root  126 Apr 27 23:45 easy_install.py
drwx------ 11 root root 4096 Apr 27 23:45 pip
drwx------  2 root root 4096 Apr 27 23:45 pip-9.0.1.dist-info
drwx------  5 root root 4096 Apr 27 23:45 pkg_resources
drwx------  2 root root 4096 Apr 27 23:45 __pycache__
-rw-r--r--  1 root root  119 Apr 27 23:45 README.txt
drwx------  5 root root 4096 Apr 27 23:45 setuptools
drwx------  2 root root 4096 Apr 27 23:45 setuptools-28.8.0.dist-info
+4
7

pip3 ( ):

nano /Library/Frameworks/Python.framework/Versions/3.6/bin/pip3

, :

from pip._internal import main

pip3 .

: https://github.com/pypa/pip/issues/5240

+9

sudo chmod -R a+rx /usr/local/lib/python3.6/site-packages

, ls -l /usr/local/lib/python3.6/site-packages, pip , root.

+6

, : , script pip, . , pip, main ( pip.__version__ python).

, python, pip. - pythonpath , , py3.6.

:

  • redhat, - redhat- "python ", ?

  • shebang pip script - #!/usr/bin/env python #!/usr/bin/python3.6, ?

  • PATH , ?

  • PYTHONPATH ( , sys.path python, ), ?

+1

cd /usr/bin

sudo nano pip, pip

from pip install main from pip._internal install main

.

+1

, get pip script , python. :

PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3

- . , . .

0

, , .

sudo python -m pip --version
>> pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
sudo python -m pip install numpy --upgrade
>> Requirement already up-to-date: numpy in /usr/local/lib/python2.7/site-packages (1.14.2)
0

ImportError: 'main'

Faced the same problem as soon as I updated it to Python version 10. I got a solution in https://github.com/pypa/pip/issues/5240 Just restarting the terminal worked for me.

-1
source

Source: https://habr.com/ru/post/1675880/


All Articles