Python project root dir
import os
ROOT_DIR = os.path.abspath(os.curdir)
Python project root dir
import os
ROOT_DIR = os.path.abspath(os.curdir)
get root path python
import os
abs_path = os.path.abspath()
project_dir = os.path.dirname(abs_path)
how to access a file from root folder in python project
from from_root import from_root, from_here
# path to config file at the root of your project
# (no matter from what file of the project the function is called!)
config_path = from_root('config.json')
# path to the data.csv file at the same directory where the callee script is located
# (has nothing to do with the current working directory)
data_path = from_here('data.csv')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us