install python package to sys.path

Viewed 1914

I am new to python3 and I want to create a package that I can import from other python script.

So I created my package and I run

python3 setup.py sdist

to create my tarball.

when I move it to another directory to untar it and then install the package with

python3 setup.py install -user --prefix=

it's fine there is no error and it install in my site-package of python and when I run python3 I can import my lib and call its function.

But when I want to import this package in a script it tell me

ImportError: No module named test_package.pck1.addition

I know that I can add

import sys
sys.path.append('./test_package.0.1')

to fix it but I want to avoid that because it would mean always having to modify the path to the package when trying to use it in another script.

So How can I import my package without modifying the sys.path. Or how can I an install my package so that my script won't need that.

I tried a lot of installation process (using pip3, trying different option etc) nothing work as I expect it.

1 Answers
Related