Frequently asked Import Errors

·

1 min read

For example,
ModuleNotFoundError: No module named 'api'

it seems that Django can't find you application, it can't be related to the PYTHONPATH or DJANGO_SETTINGS_MODULE environment varaibles.

Can y please attach the settings.py file content? (specifically the apps section)
Also what is you DJANGO_SETTINGS_MODULE and PYTHONPATH environment variables?

you do so by:

echo %PYTHONPATH%
echo %DJANGO_SETTINGS_MODULE%

If you are running windows.

To conclude we should do:

run:

set DJANGO_SETTINGS_MODULE=api.coronavstech.coronavstech.settings
set PYTHONPATH=PATH-TO-COURSE\my-pytest-course;PATH-TO-COURSE\my-pytest-course\api;PATH-TO-COURSE\my-pytest-course\api\coronavstech

where PATH-TO-COURSE is the path for the directory containg your project
and then restart computer

this should fix everything.

How to do "export PYTHONPATH=." on windows powershell?

$env:PYTHONPATH = $pwd
$env:path="$env:Path;C:\Python27"

export PYTHONPATH=/d/pycode/my-pytest:/d/pycode/my-pytest/api:/d/pycode/my-pytest/api/coronavstech

export DJANGO_SETTINGS_MODULE=api.coronavstech.coronavstech.settings

echo $DJANGO_SETTINGS_MODULE

echo $PYTHONPATH