0

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!

tech_data
  • 31
  • 3

3 Answers3

0

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
Jerome
  • 103
  • 9
  • Thanks Jerome :) I was able to run once I change to Python 32 bit version ( I was running a 64 bit) – tech_data Sep 05 '21 at 19:19
  • @tech_data I am not sure that moving to 32 bits python makes it work. I have just tested your code on a 64 bits python 3.8.5 and it works like a charm. In other words, I believe that changing to 32 bits had the effect to get python and pip aligned in versions. Though I am happy it works for you ! – Jerome Sep 05 '21 at 20:33
0

maybe you have not install notion successfully. try to replace pip install notion to pip install notion --user ,after that maybe there is no error with run "import notion". good luck!

0

It is also very likely, that you named your file notion.py in your project folder. Just rename it to something else!

It helped for some people like here.

lennart
  • 88
  • 6