Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while importing QAgent from src.q_agent #8

Open
Ben1Mo opened this issue Mar 7, 2024 · 1 comment
Open

Issue while importing QAgent from src.q_agent #8

Ben1Mo opened this issue Mar 7, 2024 · 1 comment

Comments

@Ben1Mo
Copy link

Ben1Mo commented Mar 7, 2024

My machine configuration:

   Static hostname: --
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: --
           Boot ID: --
  Operating System: Ubuntu 18.04.6 LTS
            Kernel: Linux 5.4.0-150-generic
      Architecture: x86-64

Python version: 3.7.5

There is an error (1) when trying to import the QAgent class from src.q_agent. Attempting to run relative import also generates an error (2).

Error 1:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-366876298703> in <module>
      1 # No need to copy paste the same QAgent
      2 # definition in every notebook, don't you think?
----> 3 from src.q_agent import QAgent
      4 
      5 # hyper-parameters

ModuleNotFoundError: No module named 'src'

Error 2:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-135f3e1d5891> in <module>
      1 # No need to copy paste the same QAgent
      2 # definition in every notebook, don't you think?
----> 3 from ..src.q_agent import QAgent
      4 
      5 # hyper-parameters

ValueError: attempted relative import beyond top-level package


The issue is quite clear, however what would be the most suitable solution in this case? Should I mess with the PYTHONPATH variable or should I create a file one level above notebooks where I import the src module? Maybe something else?

@ahforoughi
Copy link

Hi,
Just move the src folder into the notebook path. This solved my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants