0

I'm trying to install Django v3.0.6 (or any other v3.x.y) in my macOS. Following are the steps that I've done:

  • installed python3 using homebrew, then ran sudo pip3 install virtualenv,
  • navigating into my target project folder, ran virtualenv venv -p python3.
  • After activating it, ran pip install Django==3.0.6. This resulted in a successful installation of Django 3.0.6.

However, when I run django-admin.py startproject myproject I immediately get the following error:

from: can't read /var/mail/django.utils.version
/usr/local/bin/django-admin.py: line 3: syntax error near unexpected token `('
/usr/local/bin/django-admin.py: line 3: `VERSION = (3, 0, 6, 'final', 0)'

Trying to to run this django-admin.py command using the virtualenv is actually my second attempt. I initially started trying with installing Django directly in my machine, not using virtualenv, which also resulted in the same error. My assumption is that happened because the default python version in my machine/OS is 2.7. Any help would be greatly appreciated!

1 Answer 1

1

Try using the complete path of your django-admin.py from your virtualenv.

/absolute-path/venv/bin/django-admin startproject myproject
Sign up to request clarification or add additional context in comments.

2 Comments

thank you so much. Not exactly sure why it needs the absolute path, but it works!
on second thoughts, while this fixed the problem for the time being, any idea what would be a fix to make it so that I can only use django-admin and not prepending the full directory? @upendra243

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.