Having problems installing pip and other environment things for OSX. Going through different guides on SE (including these link, link), and everyone's solution seems to be to uninstall pip, and then install with easy_install. Problem is, easy_install gives this error:
Traceback (most recent call last):
File "/usr/local/opt/python/libexec/bin/easy_install", line 11, in <module>
load_entry_point('setuptools==36.5.0', 'console_scripts', 'easy_install-2.7')()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 570, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2755, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2409, in load
return self.resolve()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2415, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/site-packages/setuptools/__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, map
File "/usr/local/lib/python2.7/site-packages/setuptools/setuptools/__init__.py", line 160, in <module>
monkey.patch_all()
File "/usr/local/lib/python2.7/site-packages/setuptools/setuptools/monkey.py", line 67, in patch_all
distutils.core.Command = setuptools.Command
AttributeError: 'module' object has no attribute 'Command'
What's my next step? I'm trying to uninstall pip and reinstall it because pip itself was giving this same error.
Related
I recently installed python3 and I had tons of problems so decided to delete my wsl and reinstall everything since I didn't have important stuff there.
I installed python 3.10 and apparently pip but when I try to use pip to install something or just to use list I'm getting this:
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
I'm not really sure how to fix it. I've tried a few things already
also tried installing psycopg2-binary as well but same error (not sure what am I missing here, new to PostgreSQL and PyCharm)
pip install psycopg2
pip install psycopg2-binary
Error message
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==7.1.0', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2365, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'main'
first of all run easy_install --upgrade pip command to upgrade your pip.
then type and run this
from pip._internal import main
main(['install', 'psycopg2'])
After that run this
main(['install', 'psycopg2-binary'])
When I'm trying to install any package using pip it gives an error. It shows "ImportError: No module named helpers". I tried installing the helpers module using pip but the same error occurred. I'm pasting the output of the error message. Operating System: Arch Linux.
pip2 install requests
Error:
Traceback (most recent call last):
File "/usr/bin/pip2", line 11, in <module>
load_entry_point('pip==18.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2411, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/cmdoptions.py", line 22, in <module>
from pip._internal.utils.ui import BAR_TYPES
File "/usr/lib/python2.7/site-packages/pip/_internal/utils/ui.py", line 15, in <module>
from pip._vendor.progress.helpers import HIDE_CURSOR, SHOW_CURSOR, WritelnMixin
ImportError: No module named helpers
Thanks for everyone's help. I found out the solution. When I upgraded to python 3.7 pip was broken.
Executing these commands solved the issue.
rm -rf /usr/lib/python3.7/site-packages
python3.7 -m ensurepip
pip install --upgrade pip
Same can be used with Python2 as well, just replacing 3.7 with 2.7 and pip with pip2.
Some of my python packages installed with pip had conflicts with another package I tried installing using pacman. So I decided to uninstall all the packages installed with pip. I made a requirements.txt file with all the packages and started uninstalling them. It worked fine for a while but eventually gave this error:
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 479, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2703, in load_entry_point
return ep.load()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2321, in load
return self.resolve()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2327, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
ImportError: cannot import name 'requests'
I got a similar error everytime I tried running pip after that.
Setting up a new mac here. I just installed python with brew install python, but when I try to install virtualenv with sudo pip install virtualenv it returns sudo: pip: command not found.
When I try sudo easy_install pip it returns the following response
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 11, in <module>
load_entry_point('setuptools==33.1.1', 'console_scripts', 'easy_install')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2697, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
return self.resolve()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "build/bdist.macosx-10.12-intel/egg/setuptools/__init__.py", line 10, in <module>
File "build/bdist.macosx-10.12-intel/egg/setuptools/extern/__init__.py", line 1, in <module>
ImportError: No module named extern
I can't imagine what is happening, but with my old installation I had any of this problems. Any help woul be really helpful…
I update this question to post a possible solution:
curl https://bootstrap.pypa.io/get-pip.py | sudo python