Forums

problem with reportlab library.

problem with reportlab library. I can not use?

Since it requires compilation, I'm afraid reportlab can't be installed by users on Pythonanywhere. I'm sure the PA devs would consider a request to install it, since it looks like a potentially useful (and it's BSD licensed), although there are already a few PDF libraries available on PA so you might like to check whether one of those suits your purposes as well.

Hello, dev here. We'll look into getting that installed and available for you in a release soon.

thank you

thank you

Wasn't reportlab available previously? I have code that used it late last year, but now it does not work. Was reportlab removed at some point?

I thought we had it installed, but it clearly isn't. I'll investigate.

Thanks, much appreciated

Is this available yet?

I want to try it out for GANTT charts and stuff....

Starting with this howto:

  • https://code.djangoproject.com/wiki/Charts

ah, never mind... I deactivated by Virtual Env and the import worked..

I show reportlab.Version 2.7

Time to see if a .pth file will work...

Can I view it on Python 3.4 also somehow?

You can install it yourself. Either with the --user flag for pip or into a virtualenv.

How can i install Reportlab in my bash console ? Or how can i use in my code, because i installed it...? "ModuleNotFoundError: No module named 'reportlab'"

See https://help.pythonanywhere.com/pages/InstallingNewModules/

I installed ReportLab with PIP into my virtual environment. When I try to import from it like Canvas in Views of my Django app it gives me an error and says that the module is not found. I tried adding it to installed apps in Settings but no good. Any thoughts?

When I run pip install reportlab I get this:

Requirement already satisfied: reportlab in /home/BillKennish2/myvenv/lib/python3.8/site-packages (3.5.66) Requirement already satisfied: pillow>=4.0.0 in /home/BillKennish2/myvenv/lib/python3.8/site-packages (from reportlab) (8.1.2)

It would seem that it is a package rather than a module. Is that why I can't import from it?

It looks like you've not configured your website to use your virtualenv -- there is a place to enter the virtualenv about halfway down the "Web" page.

If I do that, then my WeasyPrint install doesn't work (it did without the virtual environment selected) and the Reportlab still doesn't work. If I go back to no virtual environment Weasyprint works but Reportlab still doesn't. Both modules show up in the PIP LIST in the virtual environment and without the virtual environment. I also have another virtual environment. Not sure if that is a problem if I don't point to it on the Web page.

What exact error messages do you get with WeasyPrint when you use the virtualenv?

.

ModuleNotFoundError at /golfgames/outdetails
No module named 'weasyprint'
Request Method: GET
Request URL:    https://billkennish2.pythonanywhere.com/golfgames/outdetails
Django Version: 3.1.4
Exception Type: ModuleNotFoundError
Exception Value:    
No module named 'weasyprint'
Exception Location: /home/BillKennish2/mysite/golfgames/views.py, line 20, in <module>
Python Executable:  /usr/local/bin/uwsgi
Python Version: 3.6.9
Python Path:    
['/home/BillKennish2/mysite',
 '/var/www',
 '.',
 '',
 '/var/www',
 '/home/BillKennish2/.virtualenvs/myvirtualenv/lib/python36.zip',
 '/home/BillKennish2/.virtualenvs/myvirtualenv/lib/python3.6',
 '/home/BillKennish2/.virtualenvs/myvirtualenv/lib/python3.6/lib-dynload',
 '/usr/lib/python3.6',
 '/home/BillKennish2/.virtualenvs/myvirtualenv/lib/python3.6/site-packages']
Server time:    Mon, 17 May 2021 17:39:38 -0400

[edit by admin: formatting]

The line in Views is:

from weasyprint import HTML

Same error as reportlab if I use the virtual environment

Here is what I get when I am in the virtual environment and do a PIP List in the Bash control:

(myvirtualenv) 21:40 ~ $ pip list Package Version


asgiref 3.3.1 cairocffi 1.2.0 CairoSVG 2.5.2 cffi 1.14.5 cssselect2 0.4.1 defusedxml 0.7.1 Django 3.0 html5lib 1.1 Pillow 8.2.0 pip 21.0.1 pycparser 2.20 Pyphen 0.10.0 pytz 2021.1 reportlab 3.5.67 setuptools 54.0.0 six 1.16.0 sqlparse 0.4.1 tinycss2 1.1.0 WeasyPrint 52.5 webencodings 0.5.1 wheel 0.36.2

Can we take a look at your files? We can see them from our admin interface, but we always ask for permission first.

You bet. Just be aware I am a beginner so things might not be very elegant.

Thanks!

So it looks like you've somehow managed to create a virtualenv with both Python 3.6 and 3.8 installed into it, which is a strange setup and is probably confusing things -- each one will have a different set of installed packages, which would explain the weirdness you're seeing.

I recommend that you create a completely fresh one, using the Python version that you plan to use going forward (3.8 is probably best) and then install the packages you need there, and change the setting on the "Web" page to point at the new env.

Thanks much. I'll give it a try.

It doesn't give me an error now!! Thanks. It wouldn't let me install Python 3.8 since 3.6 is what is running on my site. So I installed 3.6 and it seems okay. Now to try to get reportlab to do what I want.

Thanks for letting us know!

Hello. I have received the news that the system image will be changed. My systems used ReportLab to generate PDF reports normally in the fishnchips image (I simply had to import reportab in my web2py controllers code). Something like this: from reportlab.pdfgen import canvas from reportlab.lib import colors from reportlab.lib.pagesizes import A4, letter from reportlab.platypus import SimpleDocTemplate, Table, TableStyle When I change the image to glastonbury or haggis, I get an error when trying to create the reports: ImportError: No module named reportlab.pdfgen Is this an issue that the PA developers will resolve or is it something that I should resolve? If the latter, I would ask for your help to be able to continue using this tool. Thank you so much!

If you need to use a module, you will need to install it.