error in activation of django web application

时间:2019-04-08 13:44:29

标签: python django pycharm

I have created a virtual env that I named "f". It has been working fine for the whole time until yesterday when it gave me an error.

The code is:

import _imp  # Just the builtin component, NOT the full Python module
import sys

try:
    import _frozen_importlib as _bootstrap
except ImportError:
    from . import _bootstrap
    _bootstrap._setup(sys, _imp)
else:
    # importlib._bootstrap is the built-in import, ensure we don't create
    # a second copy of the module.
    _bootstrap.__name__ = 'importlib._bootstrap'
    _bootstrap.__package__ = 'importlib'
    try:python manage.py makemigrations

        _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py')
    except NameError:
        # __file__ is not guaranteed to be defined, e.g. if this code gets
        # frozen by a tool like cx_Freeze.
        pass
    sys.modules['importlib._bootstrap'] = _bootstrap

The result of python manage.py run server is:

File "C:\Users\hp\AppData\Local\Programs\Python\Python36\dj\f\lib\importlib\__init__.py", line 25
    try:python manage.py makemigrations
                    ^
SyntaxError: invalid syntax

Can someone help with the error?

1 个答案:

答案 0 :(得分:2)

You have (accidentally?) pasted in

python manage.py makemigrations

in that file after try:.

Remove that and you should be golden – and you should always be able to recreate your virtualenv from scratch anyway.