"failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems" PATH on mac in sage math - graphviz

I want to use graphviz for graph vizualisation. I would like to use source from graphviz:
def display(self, verbose=False):
'''
Prints the QMDD as a dot graph.
'''
filename = '.tmp.dot'
self.save_as_dot(filename, verbose)
s = Source.from_file(filename)
s.view()
os.remove(filename)
# Can't manage to properly remove file .tmp.dot.pdf
I always experience this error message :
""failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH.""
I'm using a mac and a sage math in a jupyter notebook.
I've already tried to do pip3 install graphviz and brew install graphviz. Furthermore I had the path : "/Library/SageMath/local/lib/python3.9/site-packages/graphviz" to the system path but each solutions didn't work.

Try this:
conda install python-graphviz
It worked for me!

Related

METIS Installation on google colab

Following this source I would like to install METIS and the Python wrapper in colab:
https://github.com/james77777778/metis_python
The installation steps are listed as the following:
Download and extract metis-5.1.0.tar.gz from METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering
cd metis-5.1.0
make config shared=1 prefix=~/.local/
make install
export METIS_DLL=~/.local/lib/libmetis.so
pip3 install metis-python
However, I'm not sure how to do steps 2-4 in colab specifically and so I get the following error:
RuntimeError: Could not locate METIS dll. Please set the METIS_DLL environment variable to its full path.
Thanks!
The issue seems to be the location of the libmetis.so file. Copying the file to /usr/lib and updating the path for the environmental variable successfully completes the process:
import requests
import tarfile
# Download and extract the file
url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz"
response = requests.get(url, stream=True)
file = tarfile.open(fileobj=response.raw, mode="r|gz")
file.extractall(path=".")
# Change working directory
%cd metis-5.1.0
# The remaining steps as you have shown in the question, with updated path
!make config shared=1 prefix=~/.local/
!make install
!cp ~/.local/lib/libmetis.so /usr/lib/libmetis.so
!export METIS_DLL=/usr/lib/libmetis.so
!pip3 install metis-python
import metispy as metis

PyMesh problems with Setup on Windows10 and Error using Docker Version

I want to install PyMesh on a Windows 10 PC, if possible it should be installed in the side-packages of an interpreter delivered with the IDE we use.
I tried the way to run the setup discribed here
https://pymesh.readthedocs.io/en/latest/installation.html
so the part :
git clone https://github.com/PyMesh/PyMesh.git
cd PyMesh
git submodule update --init
worked without any problems.
I am not sure on windows if I now just can write
set PYMESH_PATH = path
and if i can use the path "...\PyMesh\PyMesh" here?
so i left out this part
I installed numpy and scipy (allready installed)
and nose because it is mentioned in the requirements.txt.
So my numpy scipy and nose versions are
numpy 1.19.1
scipy 1.6.0
nose 1.3.7 (same as requirenments)
and just run the setup.py with admin rights
python .\setup.py install
which also seemed to work but i got an error trying
python -c "import pymesh; pymesh.test()"
from the PyMesh folder
saying ModuleNotFoundError: No module named 'PyMesh'
or if i go up one Folder doing the same
saying AttributeError: module 'PyMesh' has no attribute 'triangle'
I found this link ImportError: No module named PyMesh
but i just dont know what i should type in there
I tried to install via pip by using pip install pymesh
but pip Installer gives me a different library.
So i tried in the docker version and in docker i tried the pymesh.load_mesh method with an stl File
but got
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
I dont know if this is just the stl format (expecting binary getting ascii or vice versa)
The stl file itself can be opened so shouldnt be corrupted.
So is there a different way to install pymesh? A wheel would be great. Is it possible to install pymesh to the side-packages of a given Interpreter? Did someone else allready had the same error in Docker and knows the issue
thank you for your help

bash: kivy: command not found

I followed the instructions in this link about Kivy installation "Using Homebrew with pip".
However, when I tried to run the code given below:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
It gave me an error:
bash: kivy: command not found
if you installed kivy with pip, you don't need a kivy command, you can use python directly.
python main.py
Because I created a virtual environment to isolate all the things that needs to be installed like kivy, and I installed cython and kivy first before the homebrew, it caused the problem. Even if I use:
python main.py
instead of
kivy main.py
What I did to solve it are the following:
1. Created a new virtual environment
2. Followed the instruction in kivy in right order: (1) homebrew, (2) Cython, then (3) Kivy.
3. Used "python" command instead of "kivy" command because I installed it using pip (refer to the commenr above). For example:
python name_of_your_file.py
Kivy documentation must be confusing that's why.

dask_dot RuntimeError visualizing

I'm following the dask documentation and have installed dask[complete] and graphviz with pip, and graphviz as a system install.
where dot gives ...\Anaconda3\envs\compute\Library\bin\dot.bat which points to the proper executable location.
Now running this fails:
import dask.array as da
x = da.ones((5,15),chunks=(5,5))
d = (x+1).dask
from dask.dot import dot_graph
dot_graph(d)
with
RuntimeError: failed to execute ['dot', '-Tpng'], make sure the Graphviz executables are on your systems' path
I'm running python 3 and dask 0.14.3 on Windows 10.
According to the anaconda packagers this should now work if you run the following:
conda install python-graphviz
Alternatively you can always install graphviz yourself using normal Windows methods. Make sure that you pip install graphviz afterwards.

Installing numpy on mac with pip: "requirements already satisfied" but "No module numpy"

I have python2.7.8 on mac, things I did:
sudo easy_install pip - worked.
pip install numpy:
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
I also did "pip upgrade numpy" - no luck. What's wrong?
Your problem is a conflict of different Python versions.
I would recommend installing Python and all the packages, such as numpy, scipy, matplotlib, pandas, etc via Brew
See this tutorial: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md
You can verify which Python you're running with which python or which python3 in Terminal.
This solution is more flexible and cleaner in my opinion than using Conda/Miniconda. However it is also a bit more lengthy to install, as you need to have Xcode, devtools installed to build everything
Could it be that you have multiple versions of python installed? What happens if you run python using the full path like this:
$ /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2
instead of just python2?
In my experience on Mac (and other OS too) it is best to go with Anaconda / Miniconda. This is especially true for packages like NumPy and others from scientific stack.
While Anaconda is a full-blown distribution with about 200 packages, Miniconda is just Python with a few basic libraries. The big advantage is that all packages install as binary. Further, it makes it very simple and stable to install multiple Python versions side by side. For example:
conda create -n py27 python=2.7
creates a new environment with Python 2.7. Activate with:
source activate py27
Now:
conda install numpy
installs NumPy cleanly.
You can do the same for Python 3.5 and switch between environments with source activate.
After jumping from one stackoverflow answer to another I found the solution!
my problems were:
numpy at different location( actually at right, expected-to-be location). It was the IDLE that looks for its own default folder where python2.7 installed.
I checked that my numpy is working like this, run this script to check it is working:
import os
import sys
import pygame
sys.path.insert(0, '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python')
import numpy
pygame.init()
print "( using __version__): " + numpy.__version__
print numpy.version.version
user_paths = os.environ['PYTHONPATH']
print(user_paths)
sys.path insertion adds additional path to IDLE, so it knows where to look for numpy.
Then I check if numpy truly imported - i just print its version. Right now it is 1.8.0rc.
I want to find a way to avoid using this syspath insertion all the time.
So far so good - for now.
I had a similiar problem with numpy. However, it was resolved by choosing the right environment. If you are using VScode, open the command palette (ctrl+shift+p) and type
Python: Select Interpreter.
From there, try choosing the right virtual environment/Interpreter.

Resources