pythonpython-importnotion-api

Python - Notion API - Can't import module


I'm trying to use Notion API for some automation processes but I am having some trouble importing the packages and I already try a lot of imports. I've this code:

from notion_database.database import Database
my_token = "my_token"
D = Database(integrations_token=my_token )
print(D.list_databases(page_size=100))

To run this code I made the following imports:

pip install notion-database
pip install notion-py
pip install "notion==0.0.25"
pip install notion

All of them were installed correctly and I don't have my script name as "notion.py" :D

But when I run my code I got:

from notion_database.database import Database
ModuleNotFoundError: No module named 'notion_database'

Does anyone know what I am doing wrong?

Thanks for the help!


Solution

  • It looks your code is fine. More likely, your python and pip points onto two different python versions.

    I would suggest you create an environment (virtualenv or pyenv) and reinstall the packages using this command:

    sudo python -m pip install notion-database
    sudo python -m pip install notion-py
    sudo python -m pip install "notion==0.0.25"
    sudo python -m pip install notion