Having an issue with my python install and various packages after trying to get to grips with pipenv (clearly didnt go well).
➜ which Python
/usr/bin/Python
➜ which python3.8
/usr/local/bin/python3.8
Then any command I run that isn't directly a python command throws a bad interpreter error
➜ pip
zsh: /usr/local/bin/pip: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory
➜ django-admin
zsh: /usr/local/bin/django-admin: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory
Not entirely sure what the cause is, so I am struggling to figure out how to resolve it. But basically any command that I run which involves a python package throws the same error
To install pip3 on Ubuntu or Debian Linux, open a new Terminal window and enter sudo apt-get install python3-pip . To install pip3 on Fedora Linux, enter sudo yum install python3-pip into a Terminal window. You will need to enter the administrator password for your computer in order to install this software.
Install pip
this way:
First download get-pip
:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then install pip
:
python3 get-pip.py
Check pip
installation:
$pip -V
pip 20.2.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
One way to solve the pip issue is to link pip with a specific python version. Say for example you want to use pip to install GeoPandas. In this example, you can link a specific python version with pip by using the command:
python3.8 -m pip install geopandas
Of course this only works if you have python3.8 installed! This should overcome the bad interpreter message without having to change any zsh or bash_profile files.
Here is a link with further explanation:
https://snarky.ca/why-you-should-use-python-m-pip/
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