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!
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
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
Related
I downgraded Pip from the most recent version using sudo python -m pip install pip==18.0 --upgrade, and now I am receiving the following error when running pip/pip3, including when trying to re-upgrade it using pip3 install --upgrade pip
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in \<module\>
from pip.\_internal import main
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_internal/__init__.py", line 42, in \<module\>
from pip.\_internal import cmdoptions
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_internal/cmdoptions.py", line 16, in \<module\>
from pip.\_internal.index import (
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_internal/index.py", line 14, in \<module\>
from pip.\_vendor import html5lib, requests, six
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/__init__.py", line 25, in \<module\>
from .html5parser import HTMLParser, parse, parseFragment
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/html5parser.py", line 8, in \<module\>
from . import \_tokenizer
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/\_tokenizer.py", line 16, in \<module\>
from .\_trie import Trie
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/\_trie/__init__.py", line 3, in \<module\>
from .py import Trie as PyTrie
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/\_trie/py.py", line 6, in \<module\>
from .\_base import Trie as ABCTrie
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/\_trie/\_base.py", line 3, in \<module\>
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)
Not sure if there's a specific reason you installed pip 18.0 as it looks incompatible with Python 3.10. It looks like in Python 3.10 collections.Mapping moved to collections.abc.Mapping. I would suggest just completely uninstalling pip and reinstalling, without using pip to do so.
In general, you should try to use the latest version of pip.
I just did a conda install of a few packages to follow a tutorial, and now I can't even import pandas.
I installed these:
fake-factory==0.7.2
Faker==0.7.3
pytz==2016.7
tzlocal==1.3.0
And now I get this:
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\api.py", line 7, in <module>
from pandas.core.arrays.integer import (
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\__init__.py", line 2, in <module>
from .base import (ExtensionArray, # noqa
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\base.py", line 21, in <module>
from pandas.core import ops
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\ops\__init__.py", line 21, in <module>
from pandas.core.construction import extract_array
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\construction.py", line 18, in <module>
from pandas.core.dtypes.base import ExtensionDtype, registry
ImportError: cannot import name 'registry' from 'pandas.core.dtypes.base' (C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\dtypes\base.py)
I tried doing a conda update pandas, but to no avail.
I also just installed luigi, not quite sure when it broke as I installed all the additional packages in one go.
Updated version of pandas package using pip3
try this in python3
pip3 install --upgrade pandas
Try updating pandas package in Anaconda:
conda install pandas=1.1.4
If no luck, try updating all packages:
conda update --all
Worked in my case.
I'm trying to use mayavi in python to visualize a pointcloud, and cannot resolve this error. I'm sure it is an easy pip install, but I am unsure of the command. Any help is much appreciated! Thanks!
BTW, I am running Ubuntu 18.04 and have tried installing scipy as mentioned here: Python import error "getfullargspec". I have also ran pip install traitsui. Additionally, I have rebooted my system.
Update:
After further digging, it appears that it may be an issue with Python versions. I was able to get it to run with Python3, but not Python 2.7 (I need it to work with python 2). I have also tried modifying the code within handler.py to getargspec instead of getfullargspec. I was given an error about trait_factory by doing this
Here is the entire printout:
Traceback (most recent call last):
File "mayavi_test.py", line 3, in <module>
from mayavi import mlab
File "/home/user/.local/lib/python2.7/site-packages/mayavi/mlab.py", line 16, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "/home/user/.local/lib/python2.7/site-packages/mayavi/tools/camera.py", line 24, in <module>
from .engine_manager import get_engine
File "/home/user/.local/lib/python2.7/site-packages/mayavi/tools/engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "/home/user/.local/lib/python2.7/site-packages/mayavi/preferences/api.py", line 4, in <module>
from .preference_manager import preference_manager
File "/home/user/.local/lib/python2.7/site-packages/mayavi/preferences/preference_manager.py", line 29, in <module>
from traitsui.api import View, Group, Item
File "/home/user/.local/lib/python2.7/site-packages/traitsui/api.py", line 37, in <module>
from .editors.api import (
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/__init__.py", line 26, in <module>
from .api import (
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/api.py", line 6, in <module>
from .array_editor import ArrayEditor
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/array_editor.py", line 34, in <module>
from ..view import View
File "/home/user/.local/lib/python2.7/site-packages/traitsui/view.py", line 41, in <module>
from .ui import UI
File "/home/user/.local/lib/python2.7/site-packages/traitsui/ui.py", line 51, in <module>
from .handler import Handler, ViewHandler
File "/home/user/.local/lib/python2.7/site-packages/traitsui/handler.py", line 27, in <module>
from inspect import getfullargspec
ImportError: cannot import name getfullargspec
The solution for this problem was to use older packages. Not all of the dependencies such as traitsui are compatible with Python 2.7. Even though an older version of mayavi was installed, the dependencies that are installed automatically are not compatible (they only support Python 3).
Here are the versions that work well together for me:
mayavi==4.6.2
traitsui==6.1.3
traits==5.2.0
numpy==1.17.4
pyface==6.1.2
To install a specific version, just run sudo pip install packageName==#.#.#
A few days ago I started getting the following error when using pip (1,2 or 3) to install.
*
Traceback (most recent call last): File "/home/c4pta1n/.local/bin/pip", line 7, in <module>
from pip._internal import main File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import ( File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL File "/usr/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 13, in <module>
from cryptography.hazmat.primitives.asymmetric import dsa, rsa File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/asymmetric/__init__.py", line 12, in <module>
#six.add_metaclass(abc.ABCMeta) AttributeError: 'module' object has no attribute 'add_metaclass'
*
pip3 install pip --ignore-installed six
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2318, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2324, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 13, in <module>
from cryptography.hazmat.primitives.asymmetric import dsa, rsa
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/asymmetric/__init__.py", line 12, in <module>
#six.add_metaclass(abc.ABCMeta)
AttributeError: 'module' object has no attribute 'add_metaclass'
I have been researching and trying to troubleshoot this issue and I have not been able to narrow down the issue.
Just prior to noticing this issue I had updated my debian system using the standard repository and had no issues of note, I had also updated a few pip modules using pip3 install --update, I believe the modules I had updated were scapy and requests
I am unable to use pip for any command that I have tried, even "pip list" or any version of pip through 3.6.
I have uninstalled and reinstalled pip, virtualenv, and tried to manually remove the six.add_metaclass-1.0* folder from my distutils folder.
Nothing I have tried has created any change that I can see and I am not able to narrow down that any issue that I see written about is indeed similar or related to this specific issue.
I am hoping to find help to narrow this problem down further, correct it or be pointed in the direction of any information that could help me.
six 1.3.0 doesn't have add_metaclass. It was released in 2013 year. Really time to upgrade it.
I found the answer to my issue. Apparently some linux versions have specific versions of pip and six that have to be installed through the distro package manager directly in order to work. There are some nuanced changes in how Debian makes use of pip, especially regarding updates, and they have coded these changes in to their package manager and not to pip. When I recompiled Python I had uninstalled the entire python framework and I went to the source url's to recombine python and to download pip and any other dependencies. I figured since I was installing directly from the source that it would be fine... If you are using CentOS, Debian,Redhat and maybe others, then you must install pip from the package manager that is managed by your distro in order to avoid running into this error somewhere down the line.
I tried to install tweepy by using different methods such as
pip install tweepy
sudo pip install tweepy
Lastly, i downloaded zip package from the github and used the command to install:
python setup.py install
Apparently, installation was completed successfully, however when i run a simple program which contains only one line such as import tweepy, the following error is thrown:
Traceback (most recent call last):
File "tweepytest.py", line 1, in <module>
import tweepy
File "build/bdist.macosx-10.6-intel/egg/tweepy/__init__.py", line 14, in <module>
File "build/bdist.macosx-10.6-intel/egg/tweepy/api.py", line 12, in <module>
File "build/bdist.macosx-10.6-intel/egg/tweepy/binder.py", line 11, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 33, in <module>
from .packages.ssl_match_hostname import CertificateError
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/packages/__init__.py", line 3, in <module>
from . import ssl_match_hostname
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 3, in <module>
from ssl import CertificateError, match_hostname
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 90, in <module>
import textwrap
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 40, in <module>
class TextWrapper:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 82, in TextWrapper
whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
AttributeError: 'module' object has no attribute 'maketrans'
You should try
pip3 install tweepy
or...
pip install git+https://github.com/tweepy/tweepy.git
Based on what you are saying. I assume you are using python3. You can have a work-around to make this work by replacing this File
File
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py on line 82
From
whitespace_trans = string.maketrans(
to
whitespace_trans = str.maketrans(
This would make the code compile for python3 docs.
There is another installation option you could try that clones a repo from GitHub:
git clone https://github.com/tweepy/tweepy.git
cd tweepy
pip install .