我正在尝试使用Google Colab上名为RedGalaxy的python库使用非官方Twitter API。Pypi平台尚未提供此包。
我曾尝试在Google colab中构建该软件包,但无法在那里使用。
!git clone https://github.com/Ristellise/RedGalaxy.git
!pip install -e ./RedGalaxy/.
输出:
Successfully built RedGalaxy
Successfully installed RedGalaxy-0.1.0 h11-0.14.0 httpcore-0.16.3 httpx-0.23.3 rfc3986-1.5.0
当我尝试导入库时:
代码:
from RedGalaxy import TwitterUser
输出:
ImportError Traceback (most recent call last)
<ipython-input-3-2f6c640e0abc> in <cell line: 3>()
1 import asyncio
2
----> 3 from RedGalaxy import TwitterUser
4
5
ImportError: cannot import name 'TwitterUser' from 'RedGalaxy' (unknown location)
使用git clone
和pip install -e ./RedGalaxy/.
导致软件包安装名称为:
-e git+https://github.com/Ristellise/RedGalaxy.git@4258602c48895e4b1b7e352479a44a3322c3722d#egg=RedGalaxy
与使用pip安装的包名进行比较:
tensorflow==2.12.0
torch @ https://download.pytorch.org/whl/cu118/torch-2.0.0%2Bcu118-cp39-cp39-linux_x86_64.whl
安装包使用!pip install git+https://github.com/Ristellise/RedGalaxy.git@main
将包名解析为
RedGalaxy @ git+https://github.com/Ristellise/RedGalaxy.git@4258602c48895e4b1b7e352479a44a3322c3722d
可以在代码中导入。