Importing Python libraries with hyphen in the name
Question:
I create a Python library. It requires a Git repository and a name. I name it my-library
and also inside the package folder my-package
.
How should I:
- install library
my-library
after I upload it to PyPI?
- import the package
my-package
after I install the library?
Answers:
You can name and install it from PyPi as "my-package" but you have to import it as "my_package"
I create a Python library. It requires a Git repository and a name. I name it my-library
and also inside the package folder my-package
.
How should I:
- install library
my-library
after I upload it to PyPI? - import the package
my-package
after I install the library?
You can name and install it from PyPi as "my-package" but you have to import it as "my_package"