Why is the api saved as hyphenated but imported underscored?

When I go to import alpaca on github, there is an api listed in many online tutorials including the github account ‘GitHub - alpacahq/alpaca-trade-api-python: Python client for Alpaca's trade API’ where we are supposed to use $ pip3 install alpaca-trade-api which is hyphenated.

Then I go to `import alpaca-trade-api’ but this generates an error in PyCharm as “module not found” which doesn’t make sense as I’ve just installed it, but I cannot import it. I imported hyphenated but its not there.

Then about a page below that same reference of hyphenated install $ pip3 install alpaca-trade-api is now supposed to be underscored from alpaca_trade_api.rest import REST, TimeFrame

Why does it change from hyphenated to underscored?

How are we as users supposed to know when or how to change the underscore to hyphenated? I spent hours and hours each month getting messages about scripts that don’t work and this is a growing issue.

Hi Andrew

It is a bit confusing that the name changes that way.

The hypen to underscore is a common change in python you might see on other packages.

This is because in python you can’t have modules or packages with hyphens in them. The package is named alpaca_trade_api, however we need to use alpaca-trade-api for pip because that is how it was released on PyPI.

In the future, I would look at documentation or articles to find example imports if there are confusions.