0
votes

While I was deployed my django app in heroku, I run:

  heroku run python3  manage.py migrate

and I get this messahe in my console:

  File "manage.py", line 16
  ) from exc
     ^
  SyntaxError: invalid syntax

my manage.py file is actually:

  #!~/.virtualenvs/djangodev/bin/python
  """Django's command-line utility for administrative tasks."""
  import os
  import sys


  def main():
      os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myApp3.settings')
      try:
          from django.core.management import execute_from_command_line
      except ImportError as exc:
          raise ImportError(
              "Couldn't import Django. Are you sure it's installed and "
              "available on your PYTHONPATH environment variable? Did you "
              "forget to activate a virtual environment?"
          ) from exc
      execute_from_command_line(sys.argv)

  if __name__ == '__main__':
      main()

When I run python => python3, the next message is displayed:

  Traceback (most recent call last):
    File "manage.py", line 10, in main
      from django.core.management import execute_from_command_line
  ModuleNotFoundError: No module named 'django'

  The above exception was the direct cause of the following exception:

  Traceback (most recent call last):
    File "manage.py", line 21, in <module>
      main()
    File "manage.py", line 16, in main
      ) from exc
  ImportError: Couldn't import Django. Are you sure it's installed and available       on your PYTHONPATH environment variable? Did you forget to activate a virtual       environment?



  
1

1 Answers

0
votes

You need to set up a virtual enviorment first. Then install django in the virtual environment. You can do this through a thing called pipenv. you need to add this to your project by doing. python install pipenv. Then install python in that virtual enviorment by doing pipenv install django. when django installs you can then do your migrations.