[Fixed]-Python: "bad interpreter: No such file or directory" when running django-admin.py

30πŸ‘

βœ…

I’m not sure what you did to produce this error, but the fix for you is to change /usr/local/bin/django-admin.py shebang to #!/usr/bin/env python.


Actually if you install django in a virtualenv, the django-admin.py will have the shebang set to the python interpreter of your virtualenv, but this script will not be created in /usr/local/bin/.

Instead this script will be created in /<virtualenvpath>/bin/ along with activate and the virtualenv python interpreter. You should then move this script to /usr/local/bin/.

πŸ‘€mouad

2πŸ‘

For me, It was that the last program or script that i invoked didn’t correctly end. In that case (base) marks in front of your command when you are using the terminal[mac].

To deactivate the environment,

source deactivate

OR // if using conda

conda deactivate 
πŸ‘€nikdange_me

1πŸ‘

For django latest version use

django-admin startproject mysite

This works for me.

change my to your project name.
No need to use django-admin.py use django-admin only.
Activate your environment. Then use the above comment.

πŸ‘€ShiBil PK

0πŸ‘

This error can occur when you move your project to a different directory, for example, if your former directory was:
/Users/theuser/complete-ml-ds/sample_project/env/bin/python3-config
then it has to be updated to the new directory at the very top of python3-config file

Update the directory information:

!/Users/theuser/complete-ml-ds/sample_project/env/bin/python3.8

with your new directory

πŸ‘€coder3

0πŸ‘

I uninstalled and reinstalled Django to resolve this issue

pip uninstall django

Then pip install django.

P.S. don’t forget to install the same Django version as what you were using.

πŸ‘€ImportError

Leave a comment