No module named django but it is installed

Probably, pip installs packages into dist-packages directory, which is not included into PYTHONPATH environment variable. You have a couple of solutions: Create and configure virtualenv for your project, before using pip. This is the most Pythonic way Try to install Django using built-in pip module:python -m pip install django This command should install packages into site-packages directory. You may also add dist-packages to your PYTHONPATH. This question should help you: How to globally … Read more

Effect of using sys.path.insert(0, path) and sys.path(append) when loading modules

Because python checks in the directories in sequential order starting at the first directory in sys.path list, till it find the .py file it was looking for. Ideally, the current directory or the directory of the script is the first always the first element in the list, unless you modify it, like you did. From documentation – As initialized upon program … Read more

How to add to the PYTHONPATH in Windows, so it finds my modules/packages?

You know what has worked for me really well on windows. My Computer > Properties > Advanced System Settings > Environment Variables > Just add the path as C:\Python27 (or wherever you installed python) OR Then under system variables I create a new Variable called PythonPath. In this variable I have C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\other-folders-on-the-path This is the … Read more

Permanently add a directory to PYTHONPATH?

You need to add your new directory to the environment variable PYTHONPATH, separated by a colon from previous contents thereof. In any form of Unix, you can do that in a startup script appropriate to whatever shell you’re using (.profile or whatever, depending on your favorite shell) with a command which, again, depends on the … Read more