Trying to use igraph on Windows, but python can't load cairo - python

I've been trying to use igraph in python for network analysis, but whenever I try to import igraph I get the following error:
OSError: no library called "cairo" was found
cannot load library 'C:\Users\Nate\Anaconda3\libcairo-2.dll': error 0x7e
cannot load library 'libcairo.so.2': error 0x7e
cannot load library 'libcairo.2.dylib': error 0x7e
cannot load library 'libcairo-2.dll': error 0x7e
I followed the directions here:
How to install cairo on Windows
to install cairo through GTK, but I'm still getting this error message. I was able to get msys64 (https://www.gtk.org/docs/installations/windows/) working, and that seemed to install the one libcairo-2.dll and I copied it into my anaconda directory, but I couldn't find the other missing files. In the error message, you can see that anaconda recognizes the dll, but can't load it.
One step I was not able to follow from the linked instructions was cabal install gtk2hs-buildtools then cabal install gtk. I added the msys64 directory to my windows path, but the cabal command was not recognized in the msys64 or windows command lines.
Please help this newbie if you can!

Thanks Vincent Traag! That worked, and was much simpler than any of the methods I had previously seen!
For anyone finding this later execute this command in the Anaconda Powershell to install igraph for python:
conda install -c conda-forge python-igraph

Related

ImportError: DLL load failed while importing cv2

When I install OpenCV, I get an error as shown below. What should I do?
ImportError: DLL load failed: The specified module could not be found.
Installing OpenCV
To install a package in Jupyter Notebook, you can use the magic %pip command.
%pip install opencv-python
If the above command doesn't work on IPython < 7.3, you can try this command instead.
!pip install --user opencv-python
Demonstration
Let's see it in action. First, you insert a new cell, type in either of the two commands above, and then execute the cell using the Ctrl + Enter shortcut.
You should now be able to import and use OpenCV without any errors.
This is usually a dependency issue. Just .pyd is not enough (all .DLLs are required).
On Windows add entries to .dll into PATH environment variable (not enough for Python 3.8 with updated security policies)

error while import pytorch module. (The specified module could not be found.)

I just newly install python 3.8 via anaconda installer and install pytorch using command
conda install pytorch torchvision cpuonly -c pytorch
when i try to import torch, I got this error message.
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\chunc\anaconda3\lib\site-packages\torch\lib\asmjit.dll" or one of its dependencies.
I can see dll files are still in the directory.
I ran Dependency Walker and it gave me this result.
I am with this problem for a day.
What should i do if i want to use PyTorch module?
I had the same problem, you should check if you installed Microsoft Visual C++ Redistributable, because if you didn't this may lead to the DLL load failure.
Here is a link to download it: https://aka.ms/vs/16/release/vc_redist.x64.exe
Problem solved by downgrade PyTorch version to 1.5.1
I tried so many different solutions but I couldn't get PyTorch to work on my main conda environment. So finally I created a new environment and installed PyTorch on it; everything worked on the first try.

Failed to load a library: cairo

I keep getting this error when trying to run the following command:
python -m weasyprint http://weasyprint.org weasyprint.pdf
The error:
raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2
I installed Weasyprint using pip install weasyprint. To install cairo i used this doc: https://weasyprint.readthedocs.io/en/latest/install.html
But, at the end of the guide, when i try to run WHERE libcairo-2.dll i get a not found error.
I have been following the guide step by step but it's not working and i keep getting the same error, i searched for various solutions but none of them fixes the issue. Any advice? Thanks in advance
You need to also install the GTK+ libraries (not just weasyprint), in order for weasyprint to render the final PDF.
You can find the installation instructions for your OS documented on weasyprint's website.
Dear Windows user, please follow these steps carefully.
Really carefully. Don’t cheat.
Besides a proper Python installation and a few Python packages,
WeasyPrint needs the Pango, cairo and GDK-PixBuf libraries. They are
required for the graphical stuff: Text and image rendering. These
libraries aren’t Python packages. They are part of GTK+ (formerly
known as GIMP Toolkit), and must be installed separately.
If you're running a 64bit version of windows you can grab the GTK installers from here.
Once you have that installed... Then running
python -m weasyprint http://weasyprint.org weasyprint.pdf
Should work as expected.
macOS Monterey, I resolved it by just brew install pango and it seems to install all the necessary dependencies including Cairo that I needed. My lucky day!

Anaconda "import georaster" error: specified module not found

I am using Anaconda3 5.2.0 for Windows 10 64 bit, which is python 3.6.5 (Anaconda3-5.2.0-Windows-x86_64.exe). I have installed this into C:\Anaconda3 and then from the anaconda prompt installed basemap:
conda install -c conda-forge basemap
conda install -c conda-forge basemap-data-files
I have used this to start building map files and everything is working fine. I then wanted to add a raster to the map using georaster.
conda install -c conda-forge georaster
This also installs gdal.
When I open Jupyter Notebook and enter the line
import georaster
I get the following error message:
ImportError: DLL load failed: The specified module could not be found.
I have tried various solutions that I have seen for related issues including installing a gdal update, fiona, and geopandas. None of these change the message.
I tried installing gdal using the binaries .whl file in conda, but despite following the advice (which said to use pip) I was not able to make it work.
pip install GDAL-2.2.4-cp37-cp37m-win_amd64.whl
resulted in an error message:
GDAL-2.2.4-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.
Finally I went looking to see if I could locate the missing DLL manually. I saw one user suggest libtiff.dll was the missing file, and indeed it was one I did not have. I downloaded it and copied it into the System32 and SysWOW64 folders. This still resulted in an error but changed the error message:
ImportError: DLL load failed: %1 is not a valid Win32 application.
However I could not find a way to stop the error from occurring. I followed the steps to register the .dll but that also had an error message from not found to not supported:
(cmd prompt in administrator mode)
regsvr32.exe /i libtiff.dll
The module "libtiff.dll" failed to load.
Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.
The specified module could not be found.
I have tried downloading from 2 other websites, neither with any success. It is feeling like every method I attempt now just hits some weird error that nobody else is seeming to have and I don't understand why.
If anyone could offer some advice I'd be very appreciative. Thank you in advance.
downloading the required *.whl file(GDAL-2.2.4-cp36-cp36m-win_amd64.whl) from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal and then copying it to a location like C:\GDAL-2.2.4-cp36-cp36m-win_amd64.whl
then pip install c:\GDAL-2.2.4-cp36-cp36m-win_amd64.whl
worked for me.
Thanks.

unable to find vcvarsall,bat error while installing simplecv on windows 10?

During the installation phase, I get this, "Unable to find vcvarsall.bat" error. The installation process did complete, though. However, I was unable to see the shell on my desktop (I am using windows) and neither was I able to open it manually. I scoured the internet for the error but was unable to find any solution for this case.
The installation process is through a superpack that downloads Python 2.7
SimpleCV is not receiving much love in the past few years, and most of it's code don't got upgrade like the libraries it depends on.
The problem you got is the Superpack trying to compile an older version of OpenCV.
When running the Superpack, you should have seen and redtext error, and if you try to run a code it should show you something like this:
File "C:\Python27\lib\site-packages\SimpleCV\base.py", line 59, in <module>
raise ImportError("Cannot load OpenCV library which is required by SimpleCV")
ImportError: Cannot load OpenCV library which is required by SimpleCV
There are a few paths you can try from there:
1. You can try to install Microsoft Visual C++ Compiler for Python 2.7
Uninstall everything SuperPack installed in your PC or it may not work
It may fixes some other uses when using pip.
Now you have to install SimpleCV again.
2. Try to install OpenCV(2.3) on your own:
You can use pip for it, just remember to chose 32bits to keep compatibility with (Super Pack)
Just run on CMD
pip install OpenCV or python -m pip install OpenCV
3. Give up on SuperPack and install everything on your own.
You can try this guide
https://github.com/sightmachine/SimpleCV#windows-7vista
Or use pip for all dependencies
numpy (Numpy+MKL make sure to install this one first)
scipy
PIL
ipython
svgwrite
pygame==1.9.1release
OpenCV
You can find a useful list of wheels here
http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
Sources:
https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/
http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
https://github.com/sightmachine/SimpleCV#windows-7vista

Categories