如何使用 Python3 安装 PyRTF?
How to install PyRTF with Python3?
我尝试从 PyPi 安装 PyRTF
,但这不起作用。
包本身可以找到:
$ pip3 search PyRTF
PyRTF (0.45) - PyRTF - Rich Text Format Document Generation
但是安装失败:
$ sudo -H pip3 install PyRTF
Collecting PyRTF
Could not find a version that satisfies the requirement PyRTF (from versions: )
No matching distribution found for PyRTF
我很困惑。
您可以使用来自 sourceforge 页面的原始 url 来获取它:
pip install https://sourceforge.net/projects/pyrtf/files/pyrtf/0.45/PyRTF-0.45.tar.gz/download
但是,老实说,我不认为这个库在项目网站上维护,最后一次更新来自 2005
,11 年前。此外,它使用以下形式的一行:
from types import StringType
仅存在于 Python 2.x
中,不存在于 3.x
中。导入它也会引发特定错误:
>>> import PyRTF
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jim/anaconda3/lib/python3.5/site-packages/PyRTF/__init__.py", line 1, in <module>
from PropertySets import *
File "/home/jim/anaconda3/lib/python3.5/site-packages/PyRTF/PropertySets.py", line 12, in <module>
from types import StringType
ImportError: cannot import name 'StringType'
所以它可能是为 Python 2.x
设计的?我不记得 StringType
是什么时候从 3.x
系列中删除的,也许它针对的是它的旧版本。
有一个 Python 3 版本的 PyRTF,称为 PyRTF3。你可以找到它 Here.
PS - 使用 pip install PyRTF3
或 pip install rtfw
作为 Python 2,pip install PyRTF
不起作用。
我尝试从 PyPi 安装 PyRTF
,但这不起作用。
包本身可以找到:
$ pip3 search PyRTF
PyRTF (0.45) - PyRTF - Rich Text Format Document Generation
但是安装失败:
$ sudo -H pip3 install PyRTF
Collecting PyRTF
Could not find a version that satisfies the requirement PyRTF (from versions: )
No matching distribution found for PyRTF
我很困惑。
您可以使用来自 sourceforge 页面的原始 url 来获取它:
pip install https://sourceforge.net/projects/pyrtf/files/pyrtf/0.45/PyRTF-0.45.tar.gz/download
但是,老实说,我不认为这个库在项目网站上维护,最后一次更新来自 2005
,11 年前。此外,它使用以下形式的一行:
from types import StringType
仅存在于 Python 2.x
中,不存在于 3.x
中。导入它也会引发特定错误:
>>> import PyRTF
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jim/anaconda3/lib/python3.5/site-packages/PyRTF/__init__.py", line 1, in <module>
from PropertySets import *
File "/home/jim/anaconda3/lib/python3.5/site-packages/PyRTF/PropertySets.py", line 12, in <module>
from types import StringType
ImportError: cannot import name 'StringType'
所以它可能是为 Python 2.x
设计的?我不记得 StringType
是什么时候从 3.x
系列中删除的,也许它针对的是它的旧版本。
有一个 Python 3 版本的 PyRTF,称为 PyRTF3。你可以找到它 Here.
PS - 使用 pip install PyRTF3
或 pip install rtfw
作为 Python 2,pip install PyRTF
不起作用。