'Cannot install any packages with pip I got this error ImportError: cannot import name 'appdirs'
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
Solution 1:[1]
I also get the same error when using ubuntu. You have to install pip installation first by typing the below command on your terminal.
sudo apt install python3-pip
After installation, you can now install your requirements.txt file.
Solution 2:[2]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | DharmanBot |
Solution 2 | krstef |