简体   繁体   English

如何用Python3安装PyRTF?

[英]How to install PyRTF with Python3?

I tried to install PyRTF from PyPi but this doesn't work. 我试图从PyPi安装PyRTF ,但这不起作用。

The package itself can be found: 包装本身可以找到:

$ pip3 search PyRTF
PyRTF (0.45)  - PyRTF - Rich Text Format Document Generation

But installing it fails: 但安装失败:

$ 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

I am confused. 我很迷惑。

You could use the raw url from the sourceforge page in order to get it: 您可以使用sourceforge页面中的原始URL来获取它:

pip install https://sourceforge.net/projects/pyrtf/files/pyrtf/0.45/PyRTF-0.45.tar.gz/download 

But, to be honest, I don't think this library is maintained on the project website the last update was from 2005 , 11 years ago.. Additionally, it uses a line of the form: 但是,说实话,我不认为这个库是在项目网站上维护的,最后一次更新是从2005 ,11年前开始的。另外,它使用了以下形式的一行:

from types import StringType

which only exists in Python 2.x not 3.x . 它只存在于Python 2.x而不是3.x Importing it raises that specific error too: 导入它也会引发特定错误:

>>> 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'

So maybe it was designed for Python 2.x ? 那么也许它是为Python 2.x设计的? I can't remember when StringType was removed from the 3.x series, maybe it targeted an old version of it. 我不记得何时从3.x系列中删除了StringType ,可能是针对它的旧版本。

There is a Python 3 version of PyRTF called PyRTF3. PyRTF的Python 3版本称为PyRTF3。 You can find it Here . 你可以在这里找到它。

PS - Use pip install PyRTF3 or pip install rtfw for Python 2, pip install PyRTF doesn't work. PS - 使用pip install PyRTF3pip install rtfw for Python 2, pip install PyRTF不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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