Search code examples
pythonpython-importpypipython-packaging

Importing Python libraries with hyphen in the name


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:

  1. install library my-library after I upload it to PyPI?
  2. import the package my-package after I install the library?

Solution

  • You can name and install it from PyPi as "my-package" but you have to import it as "my_package"