0
votes

I recently renamed my Django project in Pycharm and now I have many errors associated with Python. From my MAC terminal when I try and run:

$ django-admin startproject mobileproject

or

$ pip install django

I get:

-bash: /usr/local/bin/pip: /usr/local/opt/python/bin/python3.7: bad interpreter: No such file or directory

In Pycharm when I open most of my Django projects I now get:

invalid python interpreter selected for the project

or when i try to install pip:

$ sudo easy_install pip

i get:

sudo: unable to execute /usr/local/bin/easy_install: No such file or directory

Below was the original structure of my project:

---project
       ---project
             ---app 
                   ---models.py
                   ...etc
             ---project
                   ---settings.py
                      ...etc
             ---manage.py
       ---venv

To rename my Django project in Pycharm I right clicked on the root folder "project" and selected refactor/rename/rename project. For the rest of the folders I right clicked and selected refactor/rename and I was only given rename directory so I chose that. Below shows how I renamed my project folders.

---newproject
       ---newp
             ---newapp 
                   ---models.py
                   ...etc
             ---newp
                   ---settings.py
                      ...etc
             ---manage.py
       ---venv

After doing this I have all the errors listed above. I think choosing "rename project" instead of "rename directory" messed things up. But why do I have problems outside of Pycharm when trying to start a new project with django-admin startproject or tell pip to install django? I feel like the Python executable is in the wrong directory but I have no idea. Please Help!

Recently, homebrew upgraded to Python 3.8 and removed Python 3.7 to make it convenient for you. Welcome to the mess. In order to fix, you have to destroy your vitural envs and recreate them using python 3.8 interpreter.Melvyn
Recreate your venv. By renaming the project you basically changed the venv absolute location which is 1) not recommended 2) confuses PyCharm as it still tries to access it with the old path.Pavel Karateev
@Melvyn that must be it. So right after renaming my project I installed postgis for some reason that initiated updates of all its dependencies so python was updated to 3.8.John Mullen
@JohnMullen That would do it. I've grown accustomed to using pyenv so I don't depend on the OS version.Melvyn
@PavelKarateev thank you for your help. That's my problem. How do I destroy my old venv and recreate my venv? I tried python3 -m venv venv and got: Error: '/Users/apple/Documents/CS/MobileServiceAvailability/venv/bin/python3' and '/Users/apple/Documents/CS/MobileServiceAvailability/venv/bin/python3' are the same fileJohn Mullen