Pycharm error Django is not importable in this environment

前端 未结 17 1095
情话喂你
情话喂你 2021-02-01 13:00

I\'m getting the following errors in Pycharm.

Error: Django is not importable in this environment

It used to work well but I moved t

相关标签:
17条回答
  • 2021-02-01 13:11

    I got the same issue on OS X, and to fix it, I had to use an absolute path for the project interpreter

    /Users/myself/Projects/... is ok ~/Projects/... was not working

    0 讨论(0)
  • 2021-02-01 13:16

    I kept getting this error even after following suggestions made in other answers, like deleting .idea folder, reinstalling packages from settings->project interpreter.

    Finally, I took the venv out of the project folder and created a venev beside the project folder and deleted .idea folder from project folder.

    Then I opened the project and chose the interpreter as the newly created venv

    0 讨论(0)
  • 2021-02-01 13:16

    I had the same error. Try to name path (and project) without "_":

    ../my_project/venv -> ../my-project/venv
    
    0 讨论(0)
  • 2021-02-01 13:21

    Project interpreter, which is being used in the pycharm setting , doesn't have the django package installed. So go to

    setting->Project->project interpreter
    

    Then install django package

    it will work :)

    0 讨论(0)
  • 2021-02-01 13:22

    I had similar problem...

    I go PyCharm -> Preferences and tried to readd Django to project interpreter packages. PyCharm suddenly added everything in requirements.txt file. And now I can run project without any problem.

    0 讨论(0)
  • 2021-02-01 13:22

    As everybody said ,Check for your interpreter Was it properly configured it or not.If you created your project in virtual environment ,make sure you configured the correct python interpreter or not .The python interpreter(whole) and python interpreter(for only single project using virtualenv) are different .

    If you are using PyCharm Go to Setting->Project->project interpreter and pick the right interpreter Once you are done with that ,run the project if it runs,all set .if not check for the Edit configurations and check again for the interpreter

    0 讨论(0)
提交回复
热议问题