2016-07-01 114 views
3

我試圖從PyPi安裝PyRTF,但這不起作用。如何用Python3安裝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 

我很困惑。

回答

0

PyRTF有一個名爲PyRTF3的Python 3版本。你可以找到它Here。對於Python 2,pip install PyRTF不起作用。

3

你可以使用原始URL從sourceforge的頁面,以獲得它:

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系列中刪除,可能是針對它的舊版本。

+0

就這樣,它不起作用?:/ –

+0

看起來很@DavidAndreiNed你可以直接聯繫作者,看看這個項目的狀態是什麼。當我給出這個答案時,它在Python'3.5'中不可用。 –