Adding __init__.py not working - Module Not Found: Fixing Python Sibling Directory Import Error

preview_player
Показать описание
I've been trying to use better project structure for my ML demos, but I keep getting punched in the face by Python when importing sibling packages.

my_ml_project/
- sweet_src_code/
- models_dir/
- tests_dir/

I then usually give up and put everything in the top level dir:

my_ml_project/

This is basic stuff but I now feel such relief. No more pentagrams of salt, ritualistic animal sacrifices, and __init__.py files everywhere trying to get imports to work.

Рекомендации по теме
Комментарии
Автор

Gus, I've banging my head against this error code all day. You're a lifesaver! Thank you!

JWJD
Автор

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!

tuanphammanh
Автор

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!!

karthikash
Автор

Holy, you are a lifesaver! For some reason the absolute path of some modules didn't work, but now it does.🎉

moe
Автор

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.

CringeCrafter-uvlt
Автор

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.

quophiebarnabaue
Автор

I just started coding and this got me crying for a whole day😅

snakemonkey
Автор

Exactly what I needed, you just earned yourself a subscription, thank you for this.

okumujustine
Автор

You are a STAR!!! I was gonna give up. Thanks heaps! Best tutorial ever!!!

martinsvach
Автор

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

gheeno.
Автор

up up up - big up. Have been looking into solutions for a few days now, even created my own pypy package

tdonov
Автор

So many hours on this exact thing. You are amazing.

ksuzfuc
Автор

Thank you soo much buddy, I was stuck with this error from 6 hours. You saved my day!!

ravi_jain
Автор

Short and Sweet !
Great video, worked for me. Thanks Gus

acp
Автор

Great video! I still can't figure out why init doesn't work like it supposed to. Thanks for the solution

andrewyuan
Автор

3 days to fix this finally find your video thanks a lot

luffy
Автор

Amazing! You solve the problem trouble me for weeks!

SneezeAlpha
Автор

Earned one subscriber. Keep up good work mate

AmritpalSingh-sydl
Автор

Thank you brother for saving us the frustration. I'll also make one such video the next time I figure out such an error.

llrajsll
Автор

Awesome, Finally I resolved this error!

tangellagopal