Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install PyRTF with Python3?

I tried to install PyRTF from PyPi but this doesn't work.

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.

like image 704
buhtz Avatar asked Jul 01 '16 00:07

buhtz


2 Answers

There is a Python 3 version of PyRTF called PyRTF3. You can find it Here.

PS - Use pip install PyRTF3 or pip install rtfw for Python 2, pip install PyRTF doesn't work.

like image 81
Rugved Modak Avatar answered Nov 15 '22 22:11

Rugved Modak


You could use the raw url from the sourceforge page in order to get it:

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:

from types import StringType

which only exists in Python 2.x not 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? I can't remember when StringType was removed from the 3.x series, maybe it targeted an old version of it.

like image 37
Dimitris Fasarakis Hilliard Avatar answered Nov 15 '22 22:11

Dimitris Fasarakis Hilliard