python relative import

import, python

Solution

You have to add the directory to your python path.

import sys
sys.path.append("/libraries") 

But I think it might be better to either put the libraries in the folders of the projects that need it or just install them to one of the standard places already in sys.path.

Problem

I'm trying to make a relative import in python. but I can't understand the syntax and everytime I search for it here in SO, I can't get an answer: Here is my folder structure: ``` Root libraries mylibrary __init__ projects project myproject.py ``` and I want to import 'mylibrary' using a relative path, what's the syntax for doing it?

Original source

Related problems