Quantcast
Channel: Import module from subfolder - Stack Overflow
Browsing latest articles
Browse All 7 View Live

Answer by Abhijit Pritam Dutta for Import module from subfolder

Just create an empty __init__.py file and add it in root as well as all the sub directory/folder of your python application where you have other python modules. See...

View Article


Answer by Flavio Wuensche for Import module from subfolder

Say your project is structured this way:+---MyPythonProject| +---.gitignore| +---run.py| | +---subscripts| | | +---script_one.py| | | +---script_two.pyInside run.py, you can import scripts one and two...

View Article


Answer by Vivek22 for Import module from subfolder

Just to notify here. (from a newbee, keviv22)Never and ever for the sake of your own good, name the folders or files with symbols like "-" or "_". If you did so, you may face few issues. like mine,...

View Article

Answer by Rob Wouters for Import module from subfolder

There's no need to mess with your PYTHONPATH or sys.path here.To properly use absolute imports in a package you should include the "root" packagename as well, e.g.:from dirFoo.dirFoo1.foo1 import...

View Article

Answer by Max Kamenkov for Import module from subfolder

Set your PYTHONPATH environment variable. For example like this PYTHONPATH=.:.. (for *nix family).Also you can manually add your current directory (src in your case) to pythonpath:import osimport...

View Article


Import module from subfolder

I want to import subfolders as modules. Therefore every subfolder contains a __init__.py. My folder structure is like this:src\ main.py dirFoo\ __init__.py foofactory.py dirFoo1\ __init__.py foo1.py...

View Article

Answer by user418615 for Import module from subfolder

just tested and this worked:# create sub dirmkdir ./modulescreate module1.pyvim ./modules/module1.pydef hello(): print("hello have a nice day")def bye(): print("bye")vim write and quit:wqinclude...

View Article
Browsing latest articles
Browse All 7 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>