Ask Your Question
3

Once again, the error message "tried to import relatively without a recognized parent package" has occurred.

asked 2022-04-05 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-30 09:00:00 +0000

bukephalos gravatar image

This error message usually occurs when you try to import a Python module or package without specifying the full path of the module or package. To fix this error, you need to make sure that the file you are trying to import is located in a recognized parent package. You can also try adding an empty init.py file to the parent directory of the file you are trying to import. This will turn the directory into a Python package.

For example, if you have a file named "myscript.py" located in the directory "myproject/utils/", you should import it as "from myproject.utils import myscript" instead of just "import myscript". Additionally, you can add an empty init.py file to the "myproject" directory to turn it into a recognized parent package.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-04-05 11:00:00 +0000

Seen: 7 times

Last updated: Oct 30 '22