This video is life saver, I have struggle for almost 2 days, because I have to build the test also the main file in different folder from the module file. Thanks man!
Hey Gus, thanks for this informative video. This is what exactly I was looking for.. I was scratching my head to figure out how to setup a base with python and you really made my day. Thanks again!!
CLEAN, CONCISE! You are a life saver! No Hardcoded path, no implicit imporation of files. I wish __init__.py works like this, where it binds all the modules and submodiles where __init__.py is present, bit it doesnt. Thanks for this! I'll try it on my next automation project
I watched your video (like 50 other videos before this) and was already miserable about the upcoming comments saying your solution didn’t work 😢 But ohhh boy, what I found were people thanking you all day long (at least the top 5 comments)!! Now the only thing left for me to do is test your solution, and man… I’m so excited right now!! 😅
That's great but do we know why the __init__.py doesn't work? According to the documentation it should, but it doesn't (this is why I'm here, just like many of you). Unless I'm reading the documentation wrong over and over again, it says "add __init__.py everywhere and Bob's your uncle". But no... There are many things I like about python, package management isn't one of them. Anyway, got my code working, thanks for the video!
This happens when we build project from scratch in VSCode or some other Text Editor. When we use IDE like PyCharm, it still supports us to do that even __init_.py is not there. That's so weird. And this also makes .egg-info folders in the project.
thats exactly what i'm doing, the sibling problem, there is barely information about this problem around the net, it's super basic design problem... i would like to ask you if you found why it is necessary to use setup tools to overpass this issue? seems like PYCHARM or any advanced IDE recognize those modules, but in runtime it will fail and will not recognize the modules because it's not recognized the PYTHONPATH. another way to overcome this issue is to use for example: ``` parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) sys.path.append(parent_dir) ``` and only than make the desired import of the desired module for example. so by the docs of python all seems legit, but when you do it in runtime seems like things breaking (just like you wondered in the video). i would like to know if you have any explanation about that issue, thanks :)
I was so hopeful that this was the fix for me, but unfortunately I'm still getting the import not found error. Incredibly frustrating as I've spent hours now running through all the solutions on stack overflow. I have literally tried everything at this point and python still fails to identify my modules.
Hi Gus, thank you for the video. I found out that I can import the module as it is described in the Python document without creating the setup file. However, I have to run the module file first and then run the main file. If I just run the main file first, I receive the error AttributeError: module 'ecommerce.shipping' has no attribute 'calc_shipping'. Any idea what might help here please?
I was encounter the same error. For me, the real cause of the issue is that python did not recognize my project directory as a project directory with corresponding dependencies build, so I had to run 'pip install -e .' at the project directory (test_structure folder directory in the case of the video), assuming the setup.py exists and contain basic stuff (easy to find). Then the 'from...import' with absolute path would work.
Hey man, there is a saying in Turkish, nothing to shame on not knowing but not learning. Its been a long time i was searching for this type of solution to python and you saved the day. Thanks a lot!
When I try to install setuptools like you have, I get the error "import cannot be resolved from source". I'm banging my head on a wall, someone please help 🙃
i'm founded way to fix module not found, it is because this __init__.py is not founded any python scripts or just incorrect initializated python... to fix this, you need write this in __init__.py: from . import youre_python_script_name and it will be worked!!!
Gus, I've banging my head against this error code all day. You're a lifesaver! Thank you!
Thanks Jacob!
This video is life saver, I have struggle for almost 2 days, because I have to build the test also the main file in different folder from the module file. Thanks man!
I was having the same problem when learning how to create unittests and now its all good
Hey Gus, thanks for this informative video. This is what exactly I was looking for..
I was scratching my head to figure out how to setup a base with python and you really made my day.
Thanks again!!
CLEAN, CONCISE! You are a life saver! No Hardcoded path, no implicit imporation of files.
I wish __init__.py works like this, where it binds all the modules and submodiles where __init__.py is present, bit it doesnt.
Thanks for this! I'll try it on my next automation project
Thank you! And same here. It's just frustrating for mere mortals. Glad im not alone
It can get a bit frustrating when you read and interpret the docs carefully and things still don't work. You saved me some time. Thanks.
So many hours on this exact thing. You are amazing.
Glad it helped!
Thank you soo much buddy, I was stuck with this error from 6 hours. You saved my day!!
YW!
Amazing! Thanks! I knew it had to do with my setup.py file, but I couldn't find any good resources to figure out what the problem was for hours.
Exactly what I needed, you just earned yourself a subscription, thank you for this.
I watched your video (like 50 other videos before this) and was already miserable about the upcoming comments saying your solution didn’t work 😢
But ohhh boy, what I found were people thanking you all day long (at least the top 5 comments)!!
Now the only thing left for me to do is test your solution, and man… I’m so excited right now!! 😅
Thank you so much! I've been trying to fix this issue for hours. I wish I found this video earlier!
Holy, you are a lifesaver! For some reason the absolute path of some modules didn't work, but now it does.🎉
Great video! I still can't figure out why init doesn't work like it supposed to. Thanks for the solution
That's great but do we know why the __init__.py doesn't work? According to the documentation it should, but it doesn't (this is why I'm here, just like many of you). Unless I'm reading the documentation wrong over and over again, it says "add __init__.py everywhere and Bob's your uncle". But no... There are many things I like about python, package management isn't one of them. Anyway, got my code working, thanks for the video!
same!
Days of searching and finally found a solution in this. Thank you, Gus! 🙏
I HAVE BEEN SEARCHING FOR SOLUTION FOR TWO DAYS AND FINALLY I GOT IT TO WORK!!!
THANK YOU SO MUCHHHH!!!!!!!
God bless you. period!
edit; if u can please find the reason and reply to this comment
This happens when we build project from scratch in VSCode or some other Text Editor. When we use IDE like PyCharm, it still supports us to do that even __init_.py is not there. That's so weird.
And this also makes .egg-info folders in the project.
Thank you brother for saving us the frustration. I'll also make one such video the next time I figure out such an error.
Awesome!
IT.
WORKED.
THANK.
YOU.
SO.
F-ING.
MUCH!!!
YW!
dude, you safed my life! Thank you so much.
Thanks so much for sharing!
up up up - big up. Have been looking into solutions for a few days now, even created my own pypy package
the relatively and absolutely boring joke was pretty funny ngl
You are a STAR!!! I was gonna give up. Thanks heaps! Best tutorial ever!!!
Short and Sweet !
Great video, worked for me. Thanks Gus
thank you!
thats exactly what i'm doing, the sibling problem, there is barely information about this problem around the net, it's super basic design problem...
i would like to ask you if you found why it is necessary to use setup tools to overpass this issue?
seems like PYCHARM or any advanced IDE recognize those modules, but in runtime it will fail and will not recognize the modules because it's not recognized the PYTHONPATH.
another way to overcome this issue is to use for example:
```
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.append(parent_dir)
```
and only than make the desired import of the desired module for example.
so by the docs of python all seems legit, but when you do it in runtime seems like things breaking (just like you wondered in the video).
i would like to know if you have any explanation about that issue, thanks :)
Gus brother You are amazing.
Lots of thanks for this solution🤩
your welcome!
i was getting so frustrated with this issue. Thank you so much man
Thank you
from setuptools import setup, find_packages
setup(name="my",
version="0.1",
packages=find_packages(),
package_dir={'': 'src'},
)
I was so hopeful that this was the fix for me, but unfortunately I'm still getting the import not found error. Incredibly frustrating as I've spent hours now running through all the solutions on stack overflow. I have literally tried everything at this point and python still fails to identify my modules.
same here bro
2.48 minutes video saved my hours . thanks man it resovled my issue
3 days to fix this finally find your video thanks a lot
dude, thank you so much for this video! it's really helpful
You got it, bro! The struggle is real with imports and python path
Hey Gus, just wanted to thank you for the helping hand!!!)))
Earned one subscriber. Keep up good work mate
I just started coding and this got me crying for a whole day😅
Appreciate the help, That was quite frustrating.
Hi Gus, thank you for the video. I found out that I can import the module as it is described in the Python document without creating the setup file. However, I have to run the module file first and then run the main file. If I just run the main file first, I receive the error AttributeError: module 'ecommerce.shipping' has no attribute 'calc_shipping'. Any idea what might help here please?
Your shipping class does not have a function named calc_shipping... perharps you should check the name.
I was encounter the same error. For me, the real cause of the issue is that python did not recognize my project directory as a project directory with corresponding dependencies build, so I had to run 'pip install -e .' at the project directory (test_structure folder directory in the case of the video), assuming the setup.py exists and contain basic stuff (easy to find). Then the 'from...import' with absolute path would work.
Amazing! You solve the problem trouble me for weeks!
Thank you! Was struggling with this error.
Your welcome!
Good tips for Python! Thanks!
Thanks Douglas!
saved my day bro.... literally after 5 hours of my search......
I tried AI. I tried Google. All I needed was Gus.
Thank you - I was gonna put my head through my monitor.
Thank you, you saved me a lot of my time.
YW!
WoW, where did you find it from? Python is crazy.
This seems more like a hack. Does this works if I try to run this on a different computer as is or do I need to install this on every computer?
Thanks a lot dude you are a massive help
Awesome, Finally I resolved this error!
Been sh*tting myself with that module error for days man thanks a lot. Although when trying to run pip install -e . I get a virus warning
Appreciate the comment. Not sure about what your anti-virus (AV) is doing. Curious which one you are running?
Hey man, there is a saying in Turkish, nothing to shame on not knowing but not learning. Its been a long time i was searching for this type of solution to python and you saved the day. Thanks a lot!
I love that -- great saying!
That's a cool solution! Very helpful for me.
Man, you've saved me! Thanks a lot!!
Was really hoping this would work, but alas no, it doesn't appear to work with my set up
Why that is not in documentation...? Thanks man!
Thank you so much!!!!
Can't thank you more
BRO. YOU SAVED MY LIFE!!!🎉🎉
Tremendous help Gus 💯
This is a fucking lifesaver been stuck on this for almost a day.. even AI doesnt know the solution lol Thanks bro
LIFE SAVER! THANK YOU! GOD BLESS YOU!
When I try to install setuptools like you have, I get the error "import cannot be resolved from source". I'm banging my head on a wall, someone please help 🙃
Update: I've now fixed this problem, although the original issue of 'ModuleNotFoundError: No module named ' is still there for me.
Incredible. Thank you so much!!!
You're very welcome!
Thanks, it saved me! Is there any way to add this to a requirements.txt file?
THANK YOU SO MUCH FOR THIS I THOUGHT I WAS DUMB!
thank u so much brother you are gem 💎
actually such a great video man
Thanks a lot for the video, helped a lot.
Can not python -m helps here?
You just saved me a ton of nerves!
Saved the day! Awesome!
very useful, thanks 🎉
You're a lifesaver !
YW!
Hey folks! Funnily, running "pytest" causes this problem but running "python -m pytest" does not. Don't know why exactly. Just FYI :)
It works :) . Many thanks
is it still working? For me it does not work? if any one know please help me
ohh finally working 😖😖
Amazing
Thank you.
Thank you for this👍👍👍👍
You made my day 🙏
Why not just add .. to PYTHONPATH ?
Someone buy this man a beer !
Thx, very useful
Thank you sir.
👏👏👏
Thanks a lot
your welcome!
Thank you.
God
not working!!! This is clickbait, don't fall for it!!!
What do meam this works prefectly
@@කැලණිකුප්පි no, this is really clickbait lmao
i'm founded way to fix module not found, it is because this __init__.py is not founded any python scripts or just incorrect initializated python... to fix this, you need write this in __init__.py: from . import youre_python_script_name and it will be worked!!!
thank you bro, very very helpful!