简体   繁体   中英

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!

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

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!

I do not have an answer for anyone, but for those that come here in the future neither of these answers is a solution. This is all you will find online though. I would simply avoid using Notion as it fails in every aspect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM