Upgrade mishap... ImportError: module 'pip' has no attribute 'main'
joshistoast opened this issue · 5 comments
- Pip version: 10.0.1
- Python version: 3.6.5
- Operating system: MacOS 10.13.6
After having successfully upgrading to python 3.6.5, I noticed I was still on pip 9.0.3, so I had decided I would upgrade with the suggested prompt: pip install --upgrade pip
.
Upon executing this... I get a traceback:
❯ pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 67kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 851, in install
File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 462, in move_wheel_files
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/distlib/scripts.py", line 372, in make
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/distlib/scripts.py", line 276, in _make_script
if self._is_nt and not outname.endswith('.' + ext): # pragma: no cover
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/distlib/scripts.py", line 252, in _write_script
outname = os.path.join(self.target_dir, name)
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/distlib/util.py", line 430, in <lambda>
try:
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/distlib/util.py", line 428, in set_mode
def socket_timeout(seconds=15):
PermissionError: [Errno 1] Operation not permitted: '/usr/local/bin/pip'
Having not read anything like the smart one I am... I ran python -m pip install pip --upgrade
, to which I get:
Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages (10.0.1)
After thinking it worked, I ran pip -V
, what came next hurt me:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2332, in resolve
return functools.reduce(getattr, self.attrs, module)
AttributeError: module 'pip' has no attribute 'main'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/opt/python/libexec/bin/pip", line 11, in <module>
load_entry_point('pip==9.0.3', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2693, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in load
return self.resolve()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2334, in resolve
raise ImportError(str(exc))
ImportError: module 'pip' has no attribute 'main'
I searched the 7 seas, the heavens and the deepest depths of space to find related reports... but no solution worked for me!
Re-importing main
:
❯ from pip._internal import main
from: can't read /var/mail/pip._internal
Re-installing an older version:
❯ pip install --upgrade pip==9.0.3
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2332, in resolve
return functools.reduce(getattr, self.attrs, module)
AttributeError: module 'pip' has no attribute 'main'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/opt/python/libexec/bin/pip", line 11, in <module>
load_entry_point('pip==9.0.3', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2693, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in load
return self.resolve()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2334, in resolve
raise ImportError(str(exc))
ImportError: module 'pip' has no attribute 'main'
I'm in dire need of a solution
Thanks in advance for any brave individuals who'd like to search this chasm of chaos with me and find the scroll of solutions!
I still have yet to find out why in the blazes this happened... but after brew reinstall python3
... pip seemed to be in perfectly working order. Understandably so since it must be bundled.
This helps me, https://pip.pypa.io/en/stable/installing/
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
If you are using python3. do this,
python3 get-pip.py
It works for me.
i tried updated pip3 in my mac and now it has stopped working and giving me below error whenever i am typing pip3 on terminal:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/pkg_resources/init.py", line 2326, in resolve
return functools.reduce(getattr, self.attrs, module)
AttributeError: 'module' object has no attribute 'main'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in
load_entry_point('pip==7.1.2', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.4/site-packages/pkg_resources/init.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.4/site-packages/pkg_resources/init.py", line 2700, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.4/site-packages/pkg_resources/init.py", line 2318, in load
return self.resolve()
File "/usr/local/lib/python3.4/site-packages/pkg_resources/init.py", line 2328, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'main'
any suggestions?
when i upgrade pip to 18.0,i get a traceback: ImportError: module 'pip' has no attribute 'main',this helps me:
python -m pip install pip
you can try! Then you can use pip