Comments (16)
The properties.py
file has been there since forever, so the problem is most likely elsewhere. Is this the whole output? Are you using the same Python as the one Homebrew installed pygtk in? Did you create the virtualenv with --system-site-packages
? Can you import pango
from a Python shell? What about import lxml.etree
?
from weasyprint.
Is this the whole output?
No, but everything else is related to Django. I noticed something else: when I load my django view for the first time (after starting the dev server), I get a ImportError: No module named gi.repository
. Then, when I reload the page, it is replaced by ImportError: cannot import name properties
.
Are you using the same Python as the one Homebrew installed pygtk in?
I don't think so, as $ which python
outputs /usr/bin/python
(v2.7.2). Do I have to use the Homebrew's python formula ?
I also followed the last step from Homebrew:
For non-Homebrew Python, you need to amend your PYTHONPATH like so:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
Did you create the virtualenv with --system-site-packages? Can you import pango from a Python shell? What about import lxml.etree?
Yes, yes, and yes. I double checked that.
from weasyprint.
when I load my django view for the first time (after starting the dev server), I get a
ImportError: No module named gi.repository
This is it. WeasyPrint fails to import Pango, either from gi.repository.Pango
through PyGObject3-introspection or from just pango
with PyGTK.
I really don’t know how Homebrew handles Python and Python libs. How do you start Django? Can you import pango
with the same Python that Django uses?
from weasyprint.
Ok, you pointed out the right issue (I was importing cairo
in my last test). Using ./manage.py shell
, I get the same python environment than Django:
$ import pango
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named pango
$ import pygtk
# Seems to work
In /usr/local/lib/python2.7/site-packages
(my PYTHONPATH):
$ find . -iname "*pango*"
./gtk-2.0/pango.so
./gtk-2.0/pangocairo.so
Is a pango.py
needed ?
from weasyprint.
There is no pango.py
, pango.so
imports as a Python module. /usr/local/lib/python2.7/site-packages/gtk-2.0
should be in sys.path
. On my system this happens because /usr/lib/python2.7/site-packages/pygtk.pth
contains a path to the gtk-2.0
directory. Do you have something similar, maybe in another .pth file? If not try adding it. (But it should have been there…)
from weasyprint.
I have the same pygtk.pth
file containing gtk-2.0
. Plus, sys.path
seems to be correct:
>>> import sys
>>> sys.path
[..., '/usr/local/lib/python2.7/site-packages', ...]
$ ls /usr/local/lib/python2.7/site-packages
...
gtk-2.0
pygtk.pth
pygtk.py
pygtk.pyc
pygtk.pyo
...
Any thoughts ?
from weasyprint.
I finally got it working ! Analyzing this PyGTK OSX package, I noticed that the postinstall script was adding the install path to /Library/Python/2.7/site-packages/gtkredirect.pth
. So I modified it this way:
# in /Library/Python/2.7/site-packages/gtkredirect.pth
import site;
site.addsitedir('/usr/local/lib/python2.7/site-packages')
I think that brew just assume python to be installed with a brew package.
Thanks for your help Simon, you led me on the right way :)
Could you please add this step to the installation tutorial ?
from weasyprint.
'/usr/local/lib/python2.7/site-packages/gtk-2.0'
needs to be in sys.path, no just '/usr/local/lib/python2.7/site-packages'
. Did the .pth file exist before you set it to the above?
I’m not sure what happened on your system, but in any case WeasyPrint’s documentation is not the place to fix Homebrew’s PyGTK formula. I see that it has a warning about "non-Homebrew Python":
https://github.com/mxcl/homebrew/blob/master/Library/Formula/pygtk.rb#L24
Does that help, as an alternative to your fix?
from weasyprint.
If you undo these changes to your PyGTK install and got back to the default, does 35540be fix the issue? (It’s in git master.)
from weasyprint.
Closing, as I believe that 35540be fixed the issue.
Related: http://faq.pygtk.org/index.py?req=show&file=faq02.004.htp
from weasyprint.
I had this problem today while i was upgrading my django code on a server. The problem was that i didn't have pango1.0-dev installed on my system. I installed that library and everything works well now.
from weasyprint.
@marianobianchi I think yours was not exactly the same problem, since we’re not using PyGTK anymore. But thanks for sharing, I’ll remember to check the dependencies when debugging similar problems.
from weasyprint.
I know it is closed but after one year i run into the same problem again. I installed pycparser and everything seems to work fine again.
from weasyprint.
@marianobianchi Was pycparser not already installed as a (recursive) dependency?
from weasyprint.
I was having another problem and was installing all packages with "--no-deps" option in pip. That made me run into this problem again and found this old bug report. I thought it was a good idea to comment the solution that worked for me this time, but wasn't sure if this was the correct place to do it.
I have just installed using "pip install weasyprint" and it installed all the dependencies fine. So i think it's nothing to worry about...
from weasyprint.
Although the error message could definitely be better, I’m not too surprised that installing without dependencies doesn’t work.
from weasyprint.
Related Issues (20)
- Migrate to resvg? HOT 2
- Support grid-auto-flow: column HOT 4
- Fonts breaking in v62 HOT 8
- Grid support enhancements
- v62 - TypeError: can't multiply sequence by non-int of type 'float' HOT 1
- Create single page pdf for thermal printer HOT 1
- Bold font sometimes work but sometimes doesn't HOT 2
- Grid support with errors (print-css-rocks) HOT 3
- PDF/UA accessibility. Labeled strange. HOT 1
- TypeError: can only concatenate str (not "float") to str (after update from 61.2 to 62.1) HOT 5
- Tailwind color codes are incompatible HOT 2
- Issue when trying to write a pdf with the openssl_md5 function in your library HOT 1
- Failure when building wheel for 62.1 from pypi HOT 5
- Add support for ol start attribute HOT 2
- Weasyprint (62.1) broken on macOS using Python 3.12.3 from python.org HOT 3
- python api: set created date HOT 3
- Support overflow-x/y HOT 1
- display flex is breaking UI HOT 1
- tailwindcss as stylesheets: TypeError: 'NoneType' object is not subscriptable HOT 3
- Background image flickers HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weasyprint.