0

My project is: mymodule.py and test/test.py

In test.py I put: from myfunc import mymodule

but python 3.6 answers: ModuleNotFoundError: No module named 'titalicapi'

If instead I put (after reading about similar questions): from ... import mymodule the answer now is: ValueError: attempted relative import beyond top-level package

How I can let test.py to work? thanks!

asked Jan 6, 2019 at 15:38
2
  • Do you have a __init__.py in the module folder? Commented Jan 6, 2019 at 15:43
  • it's empty and it doesn't make any effect Commented Jan 6, 2019 at 15:51

1 Answer 1

1

could you perhaps show your file path? That'll help a lot.

Sample File Path
 mainfolder
 |-test.py
 | 
 |-workfiles
 |- myfunc

If your current project looks something like this, you can impprt the function and use workfiles.myfunc to access the function

from workfiles.myfunc import myfunc

I would suggest putting your main file in the root folder and sub-files/modules in other sub-folders for easier access! Hope this helped :)

answered Jan 6, 2019 at 16:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.