OCaml Graphics Error Unbound module mac OSX - graphics

I'm on OSX 10.11.6 (and sometimes 10.13.6). I've done the following (per https://stackoverflow.com/a/29609483/2630028):
brew install Caskroom/cask/xquartz
brew install ocaml
brew install pkg-config
brew install opam
opam install utop
opam install graphics
All commands are successful. Unfortunately there is no longer a --with-x11 flag with the ocaml brew formula. I tried to follow this doc: https://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Modules-and-open.
In utop:
utop # #load "graphics.cma";;
Cannot find file graphics.cma.
In a foo.ml file
open Graphics;;
and running ocamlbuild foo.native:
File "foo.ml", line 1, characters 5-13:
1 | open Graphics;;
^^^^^^^^
Error: Unbound module Graphics
Command exited with code 2.
Is there any way to get this working without having to build from source?

Have you tried something like this?
utop -I $(ocamlfind query graphics)
It worked for me. You may need to adapt the syntax to your shell (here bash).

Related

Mac install python without developer tools

I am trying to install python 3.11 without the Mac developer tools, which will give me python3.9. But when I used the vscode to open a python file, the command line installer poped up and showed the following message 'the python3 command requires the command line developer tools ....'. But I can run the python3 command in the terminal successfully.
The annoying part is the pop up window. I found some suggestions about relink or rebuild the Xcode / command line tools. But in my case, there is no Xcode path. Please let me know if there is a way to configure the path correctly.
Thank you,
I checked the link of python3 in /usr/bin
I install the python directly from the http://python.org
Do you use Homebrew in your terminal?
You can try to run brew link --overwrite --dry-run python#3.11 in your terminal to see if you need to do an update for your env path. If you do need it, the terminal will give you suggestions to relink, ex. brew link --overwrite python#3.11 or rm '/usr/local/bin/2to3-3.11'
I also had an issue when installing python3.11 through Homebrew in my terminal, it said I must use xcode-select --install to install python3.11.
So later on, I followed this video step by step, and now it works. Whenever I check python3 --version, it returns Python 3.11.1. It also allows me to install another library that depends on python3.11.
Maybe it is worth checking the current version in your terminal and seeing if need to install again the package.

How do I bring NLopt to work for Python3 on macOS Catalina with homebrew?

below you first find a summary and skip hint to the main problem and then the long version with everything. This is my first question here and I hope I didn't break any rules with making the post so long and having multiple questions...
I'm happy about any answer regarding any of the questions!!
Edit: I shortened the whole post and cut out all "questions on the way" so it's only about the nlopt difficulties now
Short
Installing nlopt via homebrew is not working because files are missing. For infos on this part ONLY skip to the bold "Main Problem(s)".
Warning: I'm pretty new to all this stuff with the shell, homebrew, etc. so I'm not really familiar with names and terms. Please be patient with me :)
Long
Reinstalling my "old" MacBook from the scratch I had to install everything again and read a lot about how things work. All the way reading countless posts and guides I learned as much as I thought I needed - and as few as possible due to the amount. Now I am stuck.
For the project I work on I need Python 3, CobraPy and NLopt. That's what I did so far (I'm listing all my commands and some resulting warnings bc I don't know what might become relevant):
I'm using the zsh shell and that's all happening at ~ if not stated otherwise. Furthermore I always installed all things being called necessary by the documentation or as precaution if stated so by guides (to which I don't have links anymore bc I'm working on all of this including more since a week))
Install XCode
via AppStore
xcode-select --install
Install homebrew
% ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
% brewup # alias brewup='brew update; brew upgrade; brew cleanup; brew doctor'
Pyenv
% brew install pyenv
==> Installing dependencies for pyenv: autoconf, openssl#1.1, pkg-config and readline
% echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
% source ~/.zshrc
preparing the Python installation
% brew install zlib sqlite sqlite3 xz openssl readline
% brewup
# and bc someone said it's necessary for no problems with build:
% export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/sqlite/lib"
% export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/sqlite/include"
Python
% brew upgrade pyenv
% pyenv install 3.8.1
% pyenv global 3.8.1
% pip install --upgrade pip
and verified it worked with version, versions, which python, python -V, pip -V
Pyenv-virtualenv & Extras
% brewup
% brew install pyenv-virtualenv
% echo -e 'if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi' >> ~/.zshrc
and testing by creating a VE, set it locally as standard in the project folder with pyenv local VE and
(VE) folder/project % pip install numpy
(VE) folder/project % sudo pip install cobra
~ % brew install grep findutils # bc "good for cobra"
NLopt
% brew install cmake
% brew install nlopt
No real problems so far. Everything seems fine.
And then I start trying to finish the NLopt Installation with the instructions from the documentation/README.md:
Main Problem(s)
continuing for nlopt after % brew install nlopt
~ % cd /usr/local/Cellar/nlopt/2.6.1
Cellar/nlopt/2.6.1 % mkdir build
Cellar/nlopt/2.6.1 % cd build
nlopt/2.6.1/build % cmake ..
CMake Error: The source directory "/usr/local/Cellar/nlopt/2.6.1" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
After some more blind tries even in nlopt/2.6.1/lib/cmake/nlopt I found that in the homebrew installation of NLopt a lot of stuff is missing compared to the git files (see GitHub NLopt) - including folders and the needed CMakeLists.txt:
Cellar/nlopt/2.6.1 % ls -1
AUTHORS
COPYING
COPYRIGHT
ChangeLog
INSTALL_RECEIPT.json
NEWS.md
README.md
TODO
include
lib
share
Question A: Did I do something wrong? I searched for people having similar problems but were not able to find help.
Question B: can I just manually download NLopt, put all the files in the directory above (replacing the things there (except for the .brew file)), just ignore that homebrew was goofing and then do the final calibration with cmake?
Regardless how we bring this to work: I read something about that if you don't use the system python then you have to link certain things anew after doing the cmake and make thing with nlopt.
Question C: when I put the new links in cmake, do I have to link the Python version I want to work with (here 3.8.1) or do I have to link the shim from pyenv? And in the first case would I have to relink every time I upgrade to a new version (what's why I hope the second one is correct)?
Recherching again I also found this side PyPI nlopt that "supports Python versions 3.6" and "setups a tool chain to build pypi wheels for the NLOpt library". This NLopt is installed via pip. Now:
Question D: Does this mean this also works if I pip install it in my VE?
And does it still need to be activated via cmake etc?
BC it's referring to the documentation on using NLopt with Python but not stating anything about the setup after pip-installing.
I don't know what to do at this point: what would be just filling and crowding my system and what will let me start working on my project? Thanks in advance :)

csvkit in2csv command not working

I followed installment instructions mentioned here
Its a simple pip install command
After that I went to my linux terminal and wrote in2csvbut got the following error:
/usr/bin/in2csv: No such file or directory
Originally I tried to install it using the command:
sudo apt-get install python3-csvkit
And the in2csv command used to work on terminal, but it appears to work under python 3 installation and I need it under my python2.7.
so I uninstalled the python3-csvkit, and installed it again using pip install, but again its not working from terminal, this way.
Any ideas why, and how to solve it?
in2csv command manual: here
I just had this problem and solved with:
sudo pip install csvkit
Without the sudo pip installs csvkit in /home/username/.local/lib/python2.7/site-packages and probably puts the executable in /home/username/.local/bin. You could avoid the sudo by adding that to your shell PATH.

Ubuntu graphviz 'sfdp' not working

I'm trying to make some Networkx Graphviz graphs.
After running: pos = nx.graphviz_layout(G, prog = 'sfdp'). An error occured, saying:
Error: remove_overlap: Graphviz not built with triangulation library
After some Google research I found that GTS is the problem. Bug report stated:
The Graphviz package is built --without-gts. This is bad news for sfdp, which complains “Error: remove_overlap: Graphviz not built with triangulation library” and fails to produce the beautiful output it creates when compiled --with-gts
Looking at comments ( on bug report ), someone said that the upstream sources for Graphviz are kept at link but I couldn't find new versions to download.
On package list I have the latest one (2.36 for trusty).
Anyone else having problems with sfdp?
Any help will be greatly appreciated!
For the ubuntu users, this is how I got grapvhiz to work on 16.04,compiling graphviz-2.40.1 from source:
In a first step , GTS needs to be installed , as graphviz looks for the gts.pc file.
Running
apt-file search gts.pc
Informs me I have to install 'libgts-dev' :
sudo apt install libgts-dev
next make pkg-config aware of the files:
pkg-config --libs gts
pkg-config --cflags gts
run configure to link in the gts library:
./configure --with-gts --prefix ~
make
make install
SFDP no longer throws the error 'Error: remove_overlap: Graphviz not built with triangulation library'
The command line codes for the pkg config I modified from this answer.
I know the question is for Ubuntu, but in case someone is having the same problem on macOS using homebrew the following worked for me:
brew reinstall graphviz --with-gts
I might have it working for Ubuntu 14.04, YMMV
Download the following graphviz packages directly from https://packages.debian.org/search?keywords=graphviz
graphviz_2.38.0-13_amd64.deb
libcgraph6_2.38.0-13_amd64.deb
libgvc6_2.38.0-13_amd64.deb
libgvpr2_2.38.0-13_amd64.deb
libltdl7_2.4.6-0.1_amd64.deb
python-pygraphviz_1.3.1-1_amd64.deb
I used version 2.38.0-13 from the stretch(testing) group.
You will need to remove the 32bit libltdl7 if present:
sudo apt-get remove libltdl7:i386
Install the packages directly with
sudo dpkg -i graphviz_2.38.0-13_amd64.deb
sudo dpkg -i libcgraph6_2.38.0-13_amd64.deb libgvc6_2.38.0-13_amd64.deb libgvpr2_2.38.0-13_amd64.deb libltdl7_2.4.6-0.1_amd64.deb
You can expect dependency errors. I cleared them with:
sudo apt-get install -f
And then re-install
sudo dpkg -i graphviz_2.38.0-13_amd64.deb
sudo dpkg -i python-pygraphviz_1.3.1-1_amd64.deb
The error no longer appeares though I would be hard pushed to say the graphs are any better.

Utop from Ocaml brew throws error

I have used ocamlbrew to install ocaml and associated utilities. I had one earlier installation also. As said in the documentation, I have used /opt for installing ocamlbrew. But when I run utop as a normal user, I am getting error
Fatal error: cannot load shared library dllunix
Reason: /usr/local/lib/ocaml/stublibs/dllunix.so: undefined symbol: caml_stat_alloc_string
Also
ldconfig -p | grep dllunix
returns nothing
This instructions are very good (and work): https://github.com/realworldocaml/book/wiki/Installation-Instructions
Install OPAM from brew, then use it for everything, including OCaml. It's best if you uninstall OCaml you've installed through brew first.

Resources