Python: How to add module from sibling folder
I have the following folder structure for my Python Project: pythonApp --> Folder |--ABC --> Package |--__init__.py --> Empty File |--abctest.py --> Module |--DEF --> Package |--__init__.py --> Empty File |--deftest.py --> Module |--Common --> Package |--__init__.py --> Empty File |--constants.py --> Module I want to import constants.pyunder the Common package in the abctest.py. Using from Common import constants throws error Module not found. Is there any solution for this.
in abctest.py, add the parent directory to python path using __file__ as current module name, then take the dirname of the dirname to compute it: import os,sys sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from Common import constants note: python 2 seems to need a __init__.py file (even empty) in Common directory to be able to recognize Common as a module, whereas python 3 can do without.
General rule about which Pandas operations on Series keep the name?
Mongoengine query set to list conversion
When using Python Windows Launcher, is there any way to prevent having to type full path?
map,lambda and append.. why doesn't it work?
Linux Nagios checks Issues: MongoDB check_mongodb.py
Django How would I filter Friend objects elegantly by name when using the built in User model?
How to use threading to get user input realtime while main still running in python
Why is python rounding this value?
Logging into a forum using Python Requests
Could bayesian network input data be probability?
Django report builder TEMPLATE_CONTEXT_PROCESSORS and Django 1.8
frames in a saved matplotlib animation are out of order
Error releasing memory for a pointer to a ctypes structure?
Dynamic Table with django form [closed]
Appending to a list from an iterated dictionary
A python script to be running on Django server