Pycharm error Django is not importable in this environment

前端 未结 17 1041
情话喂你
情话喂你 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:23

    I finally found the error. The problem was that one folder name in the virtualenv path had an accent.

    This is the old path:

    /Users/plorenzo/../telefónica/gestorSchools/venv
    

    This is the new one that works:

    /Users/plorenzo/../telefonica/gestorSchools/venv
    
    0 讨论(0)
  • 2021-02-01 13:24

    In my case, I was running the Cygwin version of Python when this error came up. Fixing it involved just adding some of cygwin's bin paths to Window's Path variable.

    Run "control sysdm.cpl" Go to the "Advanced" tab Click the "Environmental Variables" button at the bottom of this tab Find "Path" under "System Variables" Add to it ;c:/cygwin/bin;c:/cygwin/sbin;c:/cygwin/usr/local/bin

    I did not include /usr/bin, as for some reason, it is combined in to the /bin directory when viewing in windows.

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

    Ok, in my case the solution was:

    1. Install django
    2. Use @cbueche suggestion to remove the ~
    3. Switch to a another project's venv and switch back to my venv for this project

    I exited and reloaded the project a few times in there so that might also be necessary. I love PyCharm but starting a new project is always painful.

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

    steps :

     1. Choose File Option
     2. Setting
     3. Scroll to Project -> Select Python Interpreter
     4. Project Interpreter
     5. Click on Setting icon and press Add environment
     6. Create a Virtual Environment
    
    0 讨论(0)
  • 2021-02-01 13:29

    Yet another case, where my virtualenv did have Django installed, but Pycharm would still display this error.

    I eventually found out that the same virtualenv path had been duplicated in the list of available interpreters. Removing all of them and re-adding fixed it.

    The duplication happened after I copied the .idea from another machine, and re-created the virtualenv from Pycharm although it was already listed as a (broken) interpreter.

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