Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with OS X #67

Closed
GerardPaligot opened this issue Mar 26, 2015 · 10 comments
Closed

Compatibility with OS X #67

GerardPaligot opened this issue Mar 26, 2015 · 10 comments

Comments

@GerardPaligot
Copy link

Hi guys,

I'm contributor of a french open source project and we would like to integrate the support of SVG files. For that, we think to use CairoSVG. Your library works fine with linux but when I would like to use it on OS X, it cannot find import of cairo.

I'm trying to install it with:

sudo port install py27-cairo

But this solution didn't work.

Do you have any ideas about the compatibility with OS X?

@SimonSapin
Copy link
Member

I don’t use OS X, but I’ve heard of people successfully using CairoSVG (and WeasyPrint) on OS X. How to install pycairo doesn’t really have its place in this issue tracker since it’s not a CairoSVG issue at all.

Additionally, "this solution didn't work" isn’t gonna get you very far. Please see http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

@SimonSapin
Copy link
Member

That said, it is apparently typical on OS X to have a couple of separate Python installs lying around. One shipped by Apple with the system, one installed by MacPorts, etc. Are you sure you’re using the same Python as the one pycairo was installed in?

@GerardPaligot
Copy link
Author

I didn't say that CairoSVG didn't work, I said: I tried to use it, I got an error (cannot find import cairo) and I tried to install it in command line (sudo port install py27-cairo) but these solutions didn't work. I will not come here if I didn't make research on Google before. :)

If you would like more context : the project is a Django project which use virtualenv. So I control my environment (including python and its version) and I executed the command line above but the problem is always there.

Additionally, "this solution didn't work" isn’t gonna get you very far. Please see http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

I'm sorry if this issue isn't appropriate in the organisation of your project but this response isn't correct. I read this page on CairoSVG website and I didn't find a mailing list for my issue (there is a mail but this seems to be an email to one person).

@SimonSapin
Copy link
Member

Additionally, "this solution didn't work" isn’t gonna get you very far.

What I mean by this is that, without more information, I have no idea what doesn’t work or why. I am not looking at your screen. When asking for help like this, you need to provide as much information as possible. Do you see an error message? If so, what is it? (Copy/paste it entirely, with as much context as possible. Don’t paraphrase.) What exact steps did you follow to trigger it? Or do you get another kind of unexpected result? If so, what result exactly, what did you do to get it, and what did you expect instead?

The naming is a bit confusing, but Cairo, pycairo, and CairoSVG are three separate projects.

port install py27-cairo installs pycairo for the Python installed by Macports. CairoSVG is not pycairo, much less the Macports packaging of pycairo. So if this install fails (does it? do you get an error message?) that’s not something we can fix by changing CairoSVG’s code.

From "it cannot find import of cairo" I’m gonna guess that you’re seeing a ImportError: No module named 'cairo' error message. This probably means either that pycairo is not installed in the Python you’re using (perhaps because it’s a different Python install), or that you’re using virtualenv with --no-site-packages (which is now the default).

--no-site-packages hides from your virtualenv packages that are installed outside of it. port install py27-cairo installs outside of your virtualenv. If that’s what’s going on, you can re-create your virtualenv with --system-site-packages.

But again, none of this is sign of an issue in CairoSVG, and this is the CairoSVG issue tracker.

@GerardPaligot
Copy link
Author

The naming is a bit confusing, but Cairo, pycairo, and CairoSVG are three separate projects.

Ok, I didn't know that. But CairoSVG seems to have a dependency to cairo and I got an error with this dependency. This is my stacktrace:

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/management/base.py", line 284, in execute
    self.validate()
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/management/base.py", line 310, in validate
    num_errors = get_validation_errors(s, app)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors
    self._populate()
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in _populate
    self.load_app(app_name)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app
    models = import_module('%s.models' % app_name)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/debug_toolbar/models.py", line 9, in <module>
    dt_settings.patch_all()
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/debug_toolbar/settings.py", line 238, in patch_all
    patch_root_urlconf()
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/debug_toolbar/settings.py", line 226, in patch_root_urlconf
    reverse('djdt:render_panel')
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 507, in reverse
    app_list = resolver.app_dict[ns]
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 329, in app_dict
    self._populate()
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 267, in _populate
    for pattern in reversed(self.url_patterns):
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 365, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Users/Gerard/Documents/workspace-django/zds-site/zds/urls.py", line 76, in <module>
    url(r'^tutoriels/', include('zds.tutorial.urls')),
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 26, in include
    urlconf_module = import_module(urlconf_module)
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Users/Gerard/Documents/workspace-django/zds-site/zds/tutorial/urls.py", line 5, in <module>
    from . import views
  File "/Users/Gerard/Documents/workspace-django/zds-site/zds/tutorial/views.py", line 23, in <module>
    import cairosvg
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/cairosvg/__init__.py", line 27, in <module>
    from . import surface
  File "/Users/Gerard/.virtualenvs/zdsenv/lib/python2.7/site-packages/cairosvg/surface/__init__.py", line 30, in <module>
    import cairo  # pycairo
ImportError: No module named cairo

So, my environment found CairoSVG but it didn't find a module named cairo in CairoSVG.

--no-site-packages hides from your virtualenv packages that are installed outside of it. port install py27-cairo installs outside of your virtualenv. If that’s what’s going on, you can re-create your virtualenv with --system-site-packages.

That is possible. Macports seems to install dependencies outside virtualenv, so in the python of my operating system and not in virtualenv. I'll try your proposition.

But again, none of this is sign of an issue in CairoSVG, and this is the CairoSVG issue tracker.

Yes, after our conversation, I agree and I'm sorry. We can close this issue if you judge necessary. :)

@yamajik
Copy link

yamajik commented Jul 16, 2015

I have same issues, It's because the dependencies is too old, and your Mac is too new. that's it.
I am trying fixing it. and report solution here in next 5 hours.

@liZe
Copy link
Member

liZe commented Oct 26, 2015

@SquirrelMajik @GerardPaligot News about this ticket?

@liZe
Copy link
Member

liZe commented Nov 19, 2015

No news is good news

@liZe liZe closed this as completed Nov 19, 2015
@tpowell01
Copy link

Little late here, very annoying that a project doesn't download all it's dependencies. No excuses.

@liZe
Copy link
Member

liZe commented Nov 21, 2016

Little late here, very annoying that a project doesn't download all it's dependencies. No excuses.

Helping nice people dealing with their own problems during my free time is my pleasure.

Pip can't install non-Python libraries, that's why it doesn't install Cairo. But you can deal with the whole deps tree by using a package manager such as Homebrew or Macports. You can package CairoSVG for MacOS as it's done by Linux users for many Linux distributions, that would be really helpful to many users (including future-yourself). I package CairoSVG for my Linux distribution (Gentoo), it's not really harder to package it for MacOS if you have a Mac at home.

I'm also interested in extra documentation about the installation steps on MacOS. As Cairo is generally installed on Linux, we don't have this extra step in the installation chatper of the documentation. I'm a Linux user and I unfortunately can't easily write a reliable documentation on MacOS and Windows. But the documentation page of the website is plain text that you can edit in a couple of minutes. I'll be really happy and grateful to merge your pull request.

You can turn hard feelings against me into smiles from future MacOS users. No excuses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants