How to install PyRTF with Python3?
Asked Answered
H

2

6

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.

Halford answered 1/7, 2016 at 0:38 Comment(0)
F
5

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.

Ferromanganese answered 16/2, 2018 at 12:20 Comment(0)
L
4

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.

Leer answered 1/7, 2016 at 1:7 Comment(1)
It seems so @DavidAndreiNed you could contact the author directly to see what's the status for this project. When I gave this answer it wasn't usable in Python 3.5.Leer

© 2022 - 2024 — McMap. All rights reserved.