no library called "cairo" was found in Mac - python-3.x

OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 2): image not found
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 2): image not found
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 2): image not found
Error comes when i try to use weasyprint library, I have checked so many solutions but didn't find the clear solution for MacOs(BigSur version 11.6).
I'm using python version 3.7. I have tried to use weasyprint with python 3.9 for which it is working perfectly fine.
Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import weasyprint
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/weasyprint/__init__.py", line 440, in <module>
from .css import preprocess_stylesheet # noqa isort:skip
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/weasyprint/css/__init__.py", line 30, in <module>
from . import computed_values, media_queries
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/weasyprint/css/computed_values.py", line 18, in <module>
from .. import text
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/weasyprint/text.py", line 14, in <module>
import cairocffi as cairo
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/cairocffi/__init__.py", line 50, in <module>
('libcairo.so.2', 'libcairo.2.dylib', 'libcairo-2.dll'))
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/cairocffi/__init__.py", line 45, in dlopen
raise OSError(error_message) # pragma: no cover
OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 2): image not found
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 2): image not found
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 2): image not found
for Python version 3.9
(penv) shashank#Shashanks-MacBook-Pro pdf % python3 manage.py shell
Python 3.9.9 (main, Nov 21 2021, 03:16:13)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import weasyprint
>>>
It would be great help if anyone guide me through this problem. Thanks in Advance

Related

In Linux cluster system, ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96

While trying to do simulation in the Scientific Linux, I met the following error.
$ python plot_distribt.py
Loaded libmkl_rt.so for dgesvd
Loaded libmkl_rt.so for zgesvd
Traceback (most recent call last):
File "plot_distribt.py", line 32, in <module>
from mps.mps import iMPS
File "/work/wangb/DMRG/mps/mps.py", line 13, in <module>
from algorithms.linalg import np_conserved as npc
File "/work/wangb/DMRG/algorithms/linalg/np_conserved.py", line 294, in <module>
from algorithms.linalg import npc_helper
File "__init__.pxd", line 164, in init npc_helper
ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96
After creating a virtual environment, I was able to upgrade packages via pip2 install --upgrade numpy --user python, and now I have numpy-1.16.6, scipy-1.2.3 and pandas-0.24.2. However, the above ValueError still occurred.
I have also checked that after opening python within the newly-created environment, I get
Python 2.7.18 |Anaconda, Inc.| (default, Apr 23 2020, 22:42:48)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.version.version
'1.7.1'
>>> numpy.__file__
'/usr/lib64/python2.7/site-packages/numpy/__init__.pyc'
>>>
Thus, the key might be how to avoid using the numpy-1.7.1? Note that I cannot change anything in /usr/lib64/python2.7/site-packages as I am using the cluster systems from our university.
Thanks a lot in advance!

How to install nest in Python3 on Ubuntu 18.04

After following the Ubuntu/Debian installation instructions for the Nest simulator I can only import the nest module in python2.x, not python3.x
$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nest/lib/python2.7/site-packages/nest/__init__.py", line 26, in <module>
from . import ll_api # noqa
File "/nest/lib/python2.7/site-packages/nest/ll_api.py", line 72, in <module>
from . import pynestkernel as kernel # noqa
ImportError: dynamic module does not define module export function (PyInit_pynestkernel)
The default install compiles with the default Python version which is still 2 in Ubuntu.
To use Python 3, run:
cmake -Dwith-python=3 -DCMAKE_INSTALL_PREFIX:PATH=</install/path> </path/to/NEST/src>
Mentioned here in the doc.
NB: don't forget to clear the build folder to avoid issues

DLL load failed: The specified module could not be found. in matplotlib program

i was learning about matplotlib module in python i have installed the library with using command in command prompt "pip install matplotlib"
and it shows successfully installed and in python 3.7 IDLE,
when i type import matplotlib i encounter this error
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import matplotlib
File "C:\Program Files\Python37\lib\site-packages\matplotlib\__init__.py", line 200, in <module>
_check_versions()
File "C:\Program Files\Python37\lib\site-packages\matplotlib\__init__.py", line 194, in _check_versions
module = importlib.import_module(modname)
File "C:\Program Files\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.
Seems like it’s an issue with library versions https://github.com/matplotlib/matplotlib/issues/14303

How do I configure the sqlite3 module to work with Django 1.10?

So the issue is that apparently Django uses the sqlite3 that is included with python, I have sqlite3 on my computer and it works fine on its own. I have tried many things to fix this and have not found a solution yet.
Please let me know how I can fix this issue so that I can use Django on my computer.
:~$ python
Python 3.5.2 (default, Nov 6 2016, 14:10:16)
[GCC 6.2.0 20161005] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
>>> exit()
I figured out that this error was caused by me changing my python path to 3.5 from the default of 2.7.

How do I fix importing tkinter in Python 3.4.2?

I've been trying to run a colleague's script and though I have pandas running now, tkinter fails to load for some reason:
D:\>python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\tkinter\__init__.py", line 36, in <module>
from tkinter import _fix
File "C:\Python34\lib\tkinter\_fix.py", line 65, in <module>
import _tkinter
ImportError: DLL load failed: %1 is not a valid Win32 application.
I was under the impression tkinter shipped with Python 3.4?
My computer is a 64-bit machine running Windows 7 if that makes a difference?

Resources