I am quite new to programming so don't be mad if I get something wrong. I updated pip to its latest version (something like 21.x.x) and I tried to install the Detectron2 Git repo. But anything related with pip (even when checking its version) I get the following Traceback:
Traceback (most recent call last):
File "/Users/user/opt/anaconda3/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 8, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 22, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 9, in <module>
from pip._internal.utils.logging import get_indentation
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/logging.py", line 14, in <module>
from pip._internal.utils.misc import ensure_dir
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 29, in <module>
from pip._internal.locations import get_major_minor_version, site_packages, user_site
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
from . import _distutils, _sysconfig
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/exceptions.py)
Is there a solution for my problem? I also tried downgrading to an earlier version but as I said any comment with pip inside gives me this Traceback...
If anyone out there can help me I would be so grateful!
To resolve the ImportError: Cannot import name, modify the x.py file. Instead of importing the y module at the start of the x.py file, write at the end of the file. Now rerun, and you can see the following output.
I know, unfortunately too only now, that it is not a good practice to use both pacman and pip, and most of all use pip with sudo. Now I having problems using pip, as it says that it doesn't have permission to edit files. I guess this is due to the fact that files in the packages of interest are located in
There should never, ever be any reason you need to run pip in elevated mode. Had same problem on macOS as well, it's a common issue across platforms. Show activity on this post.
Python implements at least three different ways to import modules. You can use the import statement, the from statement, or the built-in __import__ function. Modules are performed during import, and new functions and classes won’t see in the module’s namespace until the def (or class) statement has been executed.
I was having the same error after upgrading to pip 20.x.x, there is a solution on GitHub(https://github.com/pypa/pip/issues/5599) which helped me to understand the problem, but it doesn't help me. So let's come to the solution
Manually remove or delete the pip
file and pip-20.2.4-py3.7.egg-info
file from the directory, which in your case is located in /Users/user/opt/anaconda3/lib/python3.7/site-packages
and for some it's in /home/user/anaconda3/lib/python3.7/site-packages
.
Now use conda remove --force pip
to completely remove pip from your system.
Finally, use conda install -c anaconda pip
to install pip in your anaconda environment.
For me, it worked, hope it will work for you too
best of luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With