问题
When I try install any packages with pip or use pip I got the following error:
ImportError: cannot import name 'appdirs'
an Example:
!pip install tweepy
Traceback (most recent call last):
File "/Users/user_name/anaconda3/bin/pip", line 6,
in <module> from pip._internal.cli.main import main
File "/Users/user_name/anaconda3/lib/python3.6/site-
packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/user_name/anaconda3/lib/python3.6/site-
packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/user_name/anaconda3/lib/python3.6/site-
packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/Users/user_name/anaconda3/lib/python3.6/site-
packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>
from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
File "/Users/user_name/anaconda3/lib/python3.6/site-
packages/pip/_internal/locations.py", line 19, in <module>
from pip._internal.utils import appdirs
File "/Users/user_name/anaconda3/lib/python3.6/site-
packages/pip/_internal/utils/appdirs.py", line 13, in <module>
from pip._vendor import appdirs as _appdirs
ImportError: cannot import name 'appdirs''''
Another example:
`pip --version
Traceback (most recent call last):
File "/Users/user_name/anaconda3/bin/pip", line 6, in <module>
from pip._internal.cli.main import main
File "/Users/user_name/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/user_name/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/user_name/anaconda3/lib/python3.6/site
packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/Users/user_name/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>
from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
File "/Users/user_name/anaconda3/lib/python3.6/site-packages/pip/_internal/locations.py", line 19, in <module>
from pip._internal.utils import appdirs
File "/Users/user_name/anaconda3/lib/python3.6/site-packages/pip/_internal/utils/appdirs.py", line 13, in <module>
from pip._vendor import appdirs as _appdirs
ImportError: cannot import name 'appdirs'
How could I fix it? Thank you
来源:https://stackoverflow.com/questions/61611793/cannot-install-any-packages-with-pip-i-got-this-error-importerror-cannot-import