Skip to content Skip to sidebar Skip to footer

Python Module Not Found But Exists In Folder

I'm trying to execute a simple PY file and I'm getting the following error: Traceback (most recent call last): File 'docker_pull.py', line 8, in import request

Solution 1:

This is a very typical issue, so I will leave this here for future reference.

If I have a project called: my_project

.
└── my_project
    ├── first_folder
    ├── second_folder
    └── third_folder

What you want to do is one of these two things:

  1. PYTHONPATH (only Python)

cd ~/my_project && export PYTHONPATH=$(pwd)

change dir to root dir, and export that dir to PYTHONPATH, so when Python runs it looks in the PYTHONPATH.

  1. PATH (everything)

cd ~/my_project && export PATH=$PATH:$(pwd)

Same as above!

This needed to live somewhere since it took me a while to figure out. So for anyone in the future who needs help with this!

Post a Comment for "Python Module Not Found But Exists In Folder"