KeyError: 'POETRY_PROJECT_FILE_PATH'
I installed coingecko_py using poetry v.1.1.13 on OSX 12.4 inside of a conda v.4.13.0 environment (coingecko_data) with the following package structure
coingecko_data
__init__.py
- coingecko_data
get_data_cg.py
poetry.lock
pyproject.toml
that lives here
(coingecko_data) ~/Code/quant_strategies/crypto_data/coingecko_data/
However, when I attempt to run get_data_cg.py
from coingecko_py import CoinGeckoAPI
def get_data(save_path):
cg = CoinGeckoAPI()
coin_ids = pd.DataFrame(cg.get_coins_list(include_platform=True))
return coin_ids
if __name__ == '__main__':
get_data('/user/data/')
I get the following error:
Traceback (most recent call last):
File "/Users/markclements/Code/quant_strategies/crypto_data/coingecko_data/coingecko_data/get_data_cg.py", line 2, in <module>
from coingecko_py import CoinGeckoAPI
File "/opt/anaconda3/envs/coingecko_data/lib/python3.9/site-packages/coingecko_py/__init__.py", line 1, in <module>
from .coingecko_py import CoingeckoApi, error_msgs
File "/opt/anaconda3/envs/coingecko_data/lib/python3.9/site-packages/coingecko_py/coingecko_py.py", line 18, in <module>
from coingecko_py.utils.api_meta import api_meta
File "/opt/anaconda3/envs/coingecko_data/lib/python3.9/site-packages/coingecko_py/utils/api_meta.py", line 10, in <module>
from coingecko_py.utils.constants import (
File "/opt/anaconda3/envs/coingecko_data/lib/python3.9/site-packages/coingecko_py/utils/constants.py", line 6, in <module>
POETRY_PROJECT_FILE_PATH = os.environ["POETRY_PROJECT_FILE_PATH"]
File "/opt/anaconda3/envs/coingecko_data/lib/python3.9/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'POETRY_PROJECT_FILE_PATH'
It seems that coingecko_py can't find these paths, which are specified in the coingecko_py/.env file in the repo. However, this file does not exist in the conda environment folder:
/opt/anaconda3/envs/coingecko_data/lib/python3.9/site-packages/coingecko_py/
when I installed coingecko_py into my coingecko_data conda environment and package directory structure above using poetry add coingecko_py.
I would like to be able to install coingecko_py in my coingecko_data conda environment in the above poetry package structure but it seems that there are issues with this out of the box? Am I missing something here? Any help you could provide to get this code working in my setup would be very much appreciated.
Thank You,
Mark
Possible solution:
- Put .env into \Lib\site-packages\coingecko_py
- Put the repo folder into working directory (the one the script runs from)
- Edit .env to setup a proper local directory where repo resides.
For instance, I put repo in "git" folder and set SWAGGER_DATA_PATH = "git/coingecko_py/swagger_data/", SWAGGER_CLIENT_PATH = "git/coingecko_py/swagger_generated/" and so on.