1

I have joined my first open source project, and with these projects, obviously come packages containing modules.

Before I delve in, this is the file structure of the project:

-Opensource-Project
    -README.md
    -main.py
    -modules
        -__init__.py
        -src
            -lyrics.py
        -tests
            -test_lyrics.py

Now inside of test_lyrics.py:

import modules

def test_lyrics():
    assert('lyrics' == modules.process_query('paradise lyrics')[0])

When I run this file, I get:

ImportError: No module named modules

I have done research, and have found many past questions suggesting this:

export PYTHONPATH="${PYTHONPATH}:/home/Opensource-Project/modules"

Now, I do this, because this is where the highest level init.py is, in the modules directory.

On top of that when I run:

>>import os
>>os.environ["PYTHONPATH"]

It returns

>>:/home/Opensource-Project/modules

And yes, it just remains the variable for the session; once I close the terminal, it is gone.

Lastly, I check .bashrc and .profile, and it is not included in there.

What can I do to permanently add this path for the project and have python recognize these packages? Keep in mind, I am new to professional software development.

Thanks

Bryan
  • 11

0 Answers0