There is an unpleasant source of confusion with relative imports. When you first learn about them, you think that they allow you to use common relative file / directory paths to refer to individual files to be imported. (Or at least I thought so.) In fact, they only allow relative paths to be used inside the package. This means that some modules within a package can use relative import syntax when they need to import other modules from the same package.
In your example, myproject.py is not in the same package as mylibrary, and in fact it is not in any package, so there is no way to use relative imports from myproject.py. Relative imports simply do not apply in this situation.
There are several things you can do to get the effect you want. One of them is to place your libraries in subdirectories of the system-packages system directory. Another is to place .PTH files in the system package site directory with such .PTH files containing paths to the storage locations of your libraries. Another is to use PYTHONPATH to point to the directories in which you store your libraries.
source share