yihong0618 / bilingual_book_maker

Make bilingual epub books Using AI translate
MIT License
6.91k stars 1k forks source link

No module named 'google.generativeai.types.generation_types' #398

Closed Space-f-Monkey closed 2 months ago

Space-f-Monkey commented 2 months ago

問題和#373一樣:

Traceback (most recent call last): File "make_book.py", line 1, in from book_maker.cli import main File "/Users/kuang/Documents/Pre_for_Translate/bilingual_book_maker-main/book_maker/cli.py", line 7, in from book_maker.translator import MODEL_DICT File "/Users/kuang/Documents/Pre_for_Translate/bilingual_book_maker-main/book_maker/translator/init.py", line 7, in from book_maker.translator.gemini_translator import Gemini File "/Users/kuang/Documents/Pre_for_Translate/bilingual_book_maker-main/book_maker/translator/gemini_translator.py", line 5, in from google.generativeai.types.generation_types import ( ModuleNotFoundError: No module named 'google.generativeai.types.generation_types'

使用 pip install -U google-generativeai 之後,還是相同結果。

我網路上爬文之後,有人說python 3.8.2不支援google-generativeai,但bbook_maker特別要求3.8.2。

Space-f-Monkey commented 2 months ago

解決的過程更新#1

不能用bbook_maker args,因為他會要求3.8.2 一定要用python3 make_book.py

但有些東西得額外安裝: pip install beautifulsoup4 pip install EbookLib pip install rich pip install tiktoken

yihong0618 commented 2 months ago

感谢我今天修复下

Space-f-Monkey commented 2 months ago

解決的過程更新#2

pip install backoff pip install openai pip install PyDeepLX pip install anthropic pip install grpcio pip install grpcio-tools (pip install gemini 這個步驟出了超多錯誤,需要安裝額外的東西,所以我裝了python3.12,改了python版本設定之後又弄了好幾的東西) 最後裝了tensorflow,然後莫名其妙就可以運轉了

我不知道問題在哪。八成是我太久沒來用bbook_maker

Space-f-Monkey commented 2 months ago

解決的過程更新#3

看來我又搞錯了。 3.9版本的問題跟3.8不一樣,會產生: Connection error. NoneType takes no arguments you can resume it next time /Users/kuang/.pyenv/versions/3.9.0/lib/python3.9/site-packages/ebooklib/epub.py:1423: FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version. If you rely on the current behaviour, change it to './/xmlns:rootfile[@media-type]' for root_file in tree.findall('//xmlns:rootfile[@media-type]', namespaces={'xmlns': NAMESPACES['CONTAINERNS']}):

換成3.8.2,檔案格式換成txt檔,似乎也有相同問題 Traceback (most recent call last): File "make_book.py", line 1, in from book_maker.cli import main File "/Users/kuang/Documents/Pre_for_Translate/bilingual_book_maker-main/book_maker/cli.py", line 7, in from book_maker.translator import MODEL_DICT File "/Users/kuang/Documents/Pre_for_Translate/bilingual_book_maker-main/book_maker/translator/init.py", line 7, in from book_maker.translator.gemini_translator import Gemini File "/Users/kuang/Documents/Pre_for_Translate/bilingual_book_maker-main/book_maker/translator/gemini_translator.py", line 5, in from google.generativeai.types.generation_types import ( ModuleNotFoundError: No module named 'google.generativeai.types.generation_types'

Space-f-Monkey commented 2 months ago

解決的過程更新#4

我又跑回去處理Gemini的問題了,似乎找到bug了:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. bbook-maker 0.8.1 requires openai>=1.1.1, but you have openai 0.28.0 which is incompatible. genai 2.1.0 requires openai<0.28.0,>=0.27.0, but you have openai 0.28.0 which is incompatible. litellm 1.35.32 requires openai>=1.0.0, but you have openai 0.28.0 which is incompatible. litellm 1.35.32 requires tiktoken>=0.4.0, but you have tiktoken 0.3.3 which is incompatible. Successfully installed openai-0.28.0

openai的版本不一樣,就算我裝了1.1.1 genai還是一樣找我碴: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. genai 2.1.0 requires openai<0.28.0,>=0.27.0, but you have openai 1.1.1 which is incompatible. litellm 1.35.32 requires tiktoken>=0.4.0, but you have tiktoken 0.3.3 which is incompatible. Successfully installed openai-1.1.1

Space-f-Monkey commented 2 months ago

我暫時放棄。

問題似乎還是我一開始問的。重新安裝之後還是一樣跳出No module named 'google.generativeai.types.generation_types'

python版本我都可以自行維持3.8.2,但google.generativeai的問題,真的就得看看程式碼裡頭怎麼改了

yihong0618 commented 2 months ago

我暫時放棄。

問題似乎還是我一開始問的。重新安裝之後還是一樣跳出No module named 'google.generativeai.types.generation_types'

python版本我都可以自行維持3.8.2,但google.generativeai的問題,真的就得看看程式碼裡頭怎麼改了

检查了一下这个最低版本是 3.9

yihong0618 commented 2 months ago

更新了下现在最低支持 3.9

Space-f-Monkey commented 2 months ago

現在我的問題似乎和現在的不太一樣,不過我用3.9試了一下,結果和昨天用3.9的時候一樣。

/Users/kuang/.pyenv/versions/3.9.0/lib/python3.9/site-packages/ebooklib/epub.py:1423: FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version. If you rely on the current behaviour, change it to './/xmlns:rootfile[@media-type]' for root_file in tree.findall('//xmlns:rootfile[@media-type]', namespaces={'xmlns': NAMESPACES['CONTAINERNS']}): 0%| | 0/10 [00:00<?, ?it/s] Animal Farm: A Fairy Story Connection error. NoneType takes no arguments you can resume it next time /Users/kuang/.pyenv/versions/3.9.0/lib/python3.9/site-packages/ebooklib/epub.py:1423: FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version. If you rely on the current behaviour, change it to './/xmlns:rootfile[@media-type]' for root_file in tree.findall('//xmlns:rootfile[@media-type]', namespaces={'xmlns': NAMESPACES['CONTAINERNS']}):

因為他說是connection error,所以我也試了一下是不是我的網路出問題,但不同網路的結果都一樣,看起來是ebooklib。

然而,我完全找不到.//xmlns:rootfile[@media-type]相關的文章⋯⋯是有一個計算Dune劇本的文章,但他就算有跳出警告,還是能做計算。

我就不確定接下來該怎麼做了。

yihong0618 commented 2 months ago

現在我的問題似乎和現在的不太一樣,不過我用3.9試了一下,結果和昨天用3.9的時候一樣。

/Users/kuang/.pyenv/versions/3.9.0/lib/python3.9/site-packages/ebooklib/epub.py:1423: FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version. If you rely on the current behaviour, change it to './/xmlns:rootfile[@media-type]' for root_file in tree.findall('//xmlns:rootfile[@media-type]', namespaces={'xmlns': NAMESPACES['CONTAINERNS']}): 0%| | 0/10 [00:00<?, ?it/s] Animal Farm: A Fairy Story Connection error. NoneType takes no arguments you can resume it next time /Users/kuang/.pyenv/versions/3.9.0/lib/python3.9/site-packages/ebooklib/epub.py:1423: FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version. If you rely on the current behaviour, change it to './/xmlns:rootfile[@media-type]' for root_file in tree.findall('//xmlns:rootfile[@media-type]', namespaces={'xmlns': NAMESPACES['CONTAINERNS']}):

因為他說是connection error,所以我也試了一下是不是我的網路出問題,但不同網路的結果都一樣,看起來是ebooklib。

然而,我完全找不到.//xmlns:rootfile[@media-type]相關的文章⋯⋯是有一個計算Dune劇本的文章,但他就算有跳出警 图片 告,還是能做計算。

我就不確定接下來該怎麼做了。

应该是网络问题我确定了下可以忽略那个 warning 图片

Space-f-Monkey commented 2 months ago

好吧,看來真的是我網路的問題,之後再看看能怎麼修正。

去年的版本還沒這問題的說。

真是讓人挫敗。

yihong0618 commented 2 months ago

你可以换个 ai 试试比如 gemini 啥的

Space-f-Monkey commented 2 months ago

我試了gpt跟claude,本來想放棄的。 但gemini還真的連線了。 為何???? 不論如何,多謝!

yihong0618 commented 2 months ago

我試了gpt跟claude,本來想放棄的。 但gemini還真的連線了。 為何???? 不論如何,多謝!

可能是网络问题,我不确定你们那有没有开通(我在 GFW 内需要美国 IP...