1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Import file from parent directory?

Discussão em 'Python' iniciado por Stack, Setembro 10, 2024.

  1. Stack

    Stack Membro Participativo

    I have the following directory structure:

    application
    tests
    main.py
    main.py


    application/main.py contains some functions.

    tests/main.py will contain my tests for these functions but I can't import the top level main.py. I get the following error:

    ImportError: Import by filename is not supported.


    I am attempting to import using the following syntax:

    import main


    What am I doing wrong?

    Continue reading...

Compartilhe esta Página