jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.28k stars 476 forks source link

ModuleNotFoundError #119

Open nissenyeh opened 4 years ago

nissenyeh commented 4 years ago

I use pip3 install notion and python3 <myscript>

but i got

ModuleNotFoundError: No module named 'notion.client'; 'notion' is not a package

from notion.client import NotionClient

# Obtain the `token_v2` value by inspecting your browser cookies on a logged-in session on Notion.so
client = NotionClient(token_v2="daf3c6be-7944-4132-8b82-035310947d89")

# Replace this URL with the URL of the page you want to edit
page = client.get_block("https://www.notion.so/840b383b9c924efc9cfe3858159098ad")

print("The old title is:", page.title)

# Note: You can use Markdown! We convert on-the-fly to Notion's internal formatted text data structure.
page.title = "The title has now changed, and has *live-updated* in the browser!"
Traceback (most recent call last):
  File "notion.py", line 1, in <module>
    from notion.client import NotionClient
  File "/Users/nissen/code/notion/notion.py", line 1, in <module>
    from notion.client import NotionClient
ModuleNotFoundError: No module named 'notion.client'; 'notion' is not a package
mara-kr commented 4 years ago

I'm getting the same -- it works if I do the following in a python REPL, but not if I run the same commands in a script. I'm running both through Poetry, so I don't think it's a library path issue.

import notion
import notion.client
client = notion.client.NotionClient(token_v2=<TOKEN>)

notion-py: 0.0.25

mara-kr commented 4 years ago

Ah, you did the same thing that I did -- since your file is notion.py, Python looks for the Notion client stuff in that file, instead of the library. Rename the file and it'll work

william-chin commented 3 years ago

I did the same thing too 😂

ashdavies commented 3 years ago

Thanks @neildryan I did the same thing too before finding this issue. Probably the same for #253