I am trying to post a question on StackOverflow but it seems like this message "Your post appears to contain code that is not properly formatted as code" keeps me from posting. I have indented every code I wrote here but I couldn't find why this is keep happening. This is the post below I was going to post.
I have created a simple framework and I uploaded it to pip
.
After downloading my own package with pip install testoy
and trying to import the function I wrote, the ModuleNotFoundError
was raised and I could not import my own function(module as well). I think this might have something to do with how I wrote __init__.py
in my framework. Is there anything that I should fix to make it work?
Framework structure
testoy
-testoy
-__init__.py
-build_sort_case.py
-test_sort.py
-.gitignore
-LICENSE
-README.md
-setup.cfg
-setup.py
__init__.py
from testoy.test_sort import decorator_sort
test.py
from testoy.test_sort import decorator_sort # ERROR!
@decorator_sort
def my_sort(arr):
pass
Error
Traceback (most recent call last): File "/home/matt/Desktop/CS/test.py", line 1, in from testoy.test_sort import decorator_sort ModuleNotFoundError: No module named 'testoy.test_sort'
test.py
do### test.py
instead.__init__.py
, it keeps making it italic because of __ in front of that name of the file. How can I get around with this?...why was that causing a problem though?
-- I would imagine because the quoted block above looks a lot like code.### \_\_init__.py
seems to do the trick but otherwise it wouldn't hurt if you use text to introduce that file:### The initialization file __init__.py