How to set path pygobject Macos catalina installing PyGTK - macos

I have installed through brew pygobject3 and it is
/usr/local/Cellar/pygobject3/3.36.1
I have tried to export to the right path but while trying to install PyGTK I am still getting:
configure: error: Package requirements (pygobject-2.0 >= 2.21.3) were not met:
No package 'pygobject-2.0' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables PYGOBJECT_CFLAGS
and PYGOBJECT_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

First make sure you have PyGObject fully installed:
$ brew install python3 gobject-introspection gtk+3 adwaita-icon-theme
If you are still getting errors, I have seen issues with the homebrew version of libffi available, which isn't linked automatically:
$ libffi_path="$(brew ls libffi | grep pkgconfig | xargs dirname)"
$ export PKG_CONFIG_PATH="${libffi_path}:${PKG_CONFIG_PATH:-}"

Related

Unable to install PyAudio on M1 Mac [PortAudio already installed]

I have visited many forums, tried diffrent methods like brew, pip, port and many more but still am facing the same error.
View this Image for more detail
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1
Can anyone help?
These steps worked on M1 Pro chips
Install portaudio
brew install portaudio
Link portaudio
brew link portaudio
Copy the path where portaudio was installed (use it in the next step)
brew --prefix portaudio
Create .pydistutils.cfg in your home directory
sudo nano $HOME/.pydistutils.cfg
then paste the following
[build_ext]
include_dirs=<PATH FROM STEP 3>/include/
library_dirs=<PATH FROM STEP 3>/lib/
Install pyaudio
pip install pyaudio
or
pip3 install pyaudio
For me it was:
brew install portaudio
python -m pip install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
This Solution is tested on M1 Macs[Please do check with other].
After the installation of HomeBrew on your system, perform the installation of PortAudio. Next follow the steps mentioned below:
Use the command to install PortAudio
sudo brew install portaudio
After successful installation of PortAudio, enter the following command.
sudo nano $HOME/.pydistutils.cfg
Next, enter the following lines in the opened window
[build_ext]
include_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/include/
include_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/lib/
Note: PortAudio location may be different for you and also don't forget to replace your PC username.
Finally run the command
pip install pyaudio
or
pip3 install pyaudio
The main challenge we're encountering here is that pyaudio doesn't know where to find the portaudio libraries since, according to the source, it only looks in these locations for darwin platform installations:
include_dirs += ['/usr/local/include', '/usr/include']
external_libraries_path += ['/usr/local/lib', '/usr/lib']
This won't do if you're using a homebrew installation of portaudio, particularly so with Apple Silicon since there isn't a pre-built wheel in PyPi. This means setuptools/pip will need to build the package from source.
There are a few ways of configuring setuptools to use additional paths, including passing arguments, using a .pydistutils.cfg file, among others, but the second option worked for me given I'm installing pyaudio to a few Python environments.
Building off of some of the answers above, you can copy the following below to install pyaudio in one go.
# Install portaudio, will print list of paths where it's been installed if already done
brew list portaudio || brew install portaudio
# Link portaudio, will print a warning if already linked
brew link portaudio
# Create a pydistutils config file with the portaudio lib paths set correctly (no copying/pasting paths required)
cat <<EOF >> .pydistutils.cfg
[build_ext]
include_dirs=`brew --prefix portaudio`/include/
library_dirs=`brew --prefix portaudio`/lib/
EOF
# install (build) package with pip
python -m pip install pyaudio
All we're doing is telling setuptools to also look for C/C++ headers where portaudio has been installed by homebrew.
vkshah has an error in his second line. It should ready library_dirs instead of include_dirs:
include_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/include/
library_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/lib/```
For me, I am running Big Sur on an M1 Mac. I followed all the instructions mentioned in other threads to:
install portaudio
arch -arm64 brew install portaudio
start a venv
python3 -m venv env
source env/bin/activate
install pyaudio
arch -arm64 pip install --no-cache-dir --global-option='build_ext' --global-option='-I/opt/homebrew/include' --global-option='-L/opt/homebrew/lib' pyaudio==0.2.11
TIP #1
If you see error on portaudio.h file not found, the solution is specifying the pyaudio version at the end. Because it kept trying to install version '0.2.12' which failed. I specify the version of pyaudio to '0.2.11' (see above).
TIP #2
After successfully installing pyaudio, you may see error PyAudio C module _portaudio, that is due to pip built it(_portaudio.cpython-36m-darwin.so) in x86_64 architecture. It's not compatible with arm64 portaudio, in this case, make sure to include arch -arm64 in front of pip to build the correct binary.
TIP #3
Use an older version of python, I personally used version 3.6.
Oh, and make sure the single quote is actually ' if you copied the command from a text editor.
Hope this helps!
first you need to download portaudio using homebrew
brew install portaudio
Then try to install pyaudio directly
pip install pyaudio
if you are getting error while installing follow below step
Or
if you are facing any error mentioned bellow you can follow these steps
error 1
option 'include_dirs' in section 'build_ext' already exists
error 2
Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
error 3
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
solution start here
after installing homebrew you have to link it
brew link portaudio
in some cases it will say that it has been already linked then simply ignore
we need path of portaudio where it is exactly installed
brew --prefix portaudio
it will gives you path of portaudio
then you have to check if pydistutils.cfg file exists or not
sudo cat $HOME/.pydistutils.cfg
if file exists then it will open else create it will below command
sudo cat $HOME/.pydistutils.cfg
so in these file we have to define proper path here
[build_ext]
include_dirs=/--PATH--/include/
library_dirs=/--PATH--/lib/
you can get that path by running below command
brew --prefix portaudio
if that path is not working then try below path
[build_ext]
include_dirs=/Users/<username>/homebrew/Cellar/portaudio/19.20140130/include/
library_dirs=/Users/<username>/homebrew/Cellar/portaudio/19.20140130/lib/
If you use mac os
Install Homebrew (insert link into the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" )
Insert command into the terminal:
brew install portaudio
Insert command into the terminal:
pip install pyaudio
p.s. sometimes you need upgrade your pip installer
These actions solved my problem (mac os Mojave 10.14.4)

Install GTK+ >= 3.16 with PyGObject bindings on MacOS 10.15

when I'm typing the command
brew install pygobject3 --with-python#2 gtk+3
I'm always getting the error message
invalid option --with-python#2
I'm getting the same error message when I want to run the gtk+3 under mac os 10.15
Namespace Gtk not available
Maybe the Version of 10.15 of MacOS the problem....
gtk+3 version 3.24.12 and pygobject3 Version 3.34.0 are installed.
Installation of homebrew for MacOS
gtk+3 version 3.24.12 and pygobject3 Version 3.34.0 are installed.
Python3.7 is installed
File "...anaconda3/envs/python37/lib/python3.7/site-packages/gi/__init__.py", line 129, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available
I would like to run the program DemonEditor on MacOS 10.15 (Catalina)
to make some settings of my engima2 satellite receiver, for this I need the requirements "GTK+ >= 3.16 with PyGObject bindings".
Maybe some of the experts can help me.
Thanks very much
Since I am the author of this program, I am forced to report that since the program is designed for Linux, it will not work on MacOS without minor changes to the program itself. But still it’s possible.
DemonEditor
Тo resolve dependencies, it is enough to install as follows:
brew install gtk+3 pygobject3 adwaita-icon-theme
pip3 install requests
Upd.
I created an experimental brunch and added small changes to the program for the possibility of testing the launch in the MacOS. Perhaps not all the functionality will work (I have not tested it), but the program should start.
Gud luck!
STRIKE. It works, I can start the DemonEditor-GUI under 10.15. I have remove all packages via the
brew remove --force $(brew list)
installed the three packages again, via
brew install python3 gtk+3 pygobject3 adwaita-icon-theme
BUT. The most important step was to add the "Installation folder" of the brew packages to my python path but execute the comand
export PYTHONPATH=/usr/local/lib/python3.7/site-packages.
My assumption is, that due to fact, that I have installed an own conda-environment for python37, the site-packages have to be added to the path.
Big thanks for the help.
On my test system, I did not set any paths or environment variables! Just installed python 3 with the command:
brew install python3
Then I installed the dependencies as described above.Then I downloaded the archive from here, and in the unpacked folder of the program I simply gave the command:
./start.py
Below is the output of the commands python3 --version and brew list
Compare with your list, perhaps this will somehow help identify the missing components.
python3 --version
Python 3.7.4
brew list
adwaita-icon-theme libepoxy
atk libffi
cairo libpng
fontconfig librsvg
freetype libtiff
fribidi lzo
gdbm openssl#1.1
gdk-pixbuf pango
gettext pcre
glib pixman
gobject-introspection pkg-config
graphite2 py2cairo
gsettings-desktop-schemas py3cairo
gtk+3 pygobject3
harfbuzz python
hicolor-icon-theme python#2
icu4c readline
jpeg sqlite
libcroco xz
Upd. For the experiment, I removed all my packages with the command:
brew remove --force $(brew list)
Then again installed by commands as described above
brew install python3 gtk+3 pygobject3 adwaita-icon-theme
Working!

OSX - Compiling training tools for Tesseract 4.0 - pango libraries not found

I am having trouble getting the configure script to recognise the pango libraries i have installed via Homebrew, which are dependancies for the training tools. So far, I've followed all steps detailed here:
https://github.com/tesseract-ocr/tesseract/issues/1453
and here:
https://github.com/tesseract-ocr/tesseract/wiki/Compiling#macos
and after running the configure script, I keep on getting these warnings in the output:
checking for pango >= 1.22.0... no
configure: WARNING: pango 1.22.0 or higher is required, but was not
found.
configure: WARNING: Training tools WILL NOT be built.
configure: WARNING: Try to install libpango1.0-dev package.
checking for cairo... no
configure: WARNING: Training tools WILL NOT be built because of
missing cairo library.
configure: WARNING: Try to install libcairo-dev?? package.
The libraries are located where they should be, at /usr/local/Cellar/pango/1.42.4_1
I've tried running the configure script as per the instructions above:
./configure CPPFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib
as well as trying to add the path to the linking flags:
./configure LDFLAGS="-L/usr/local/opt/icu4c/lib -L/usr/local/Cellar/pango/1.42.4_1/lib" CPPFLAGS="-I/usr/local/opt/icu4c/include"
and I still can't get the script to see the libraries.
Thanks in advance for any advice on how to solve this.
It looks like pango and/or cairo and maybe other libraries depend on libffi. libffi is called to be keg-only in Homebrew. Even if libffi is installed it is not linked via symbolic-links. When pkg-config tries to find a library, it also checks for its dependencies. Since libffi cannot be located pkg-config tells that cairo is not available. Therefore, one needs to call
brew link libffi --force
This should solve the problem without touching anything extra. At least it worked for my case.
This is a modified version of the answer provided by Boris [Boris: just say the word and I will delete this].
Tested on macOS 10.13.6 High Sierra.
None of the pre-existing answers worked for me - I had to explicitly add libpng to my brew requirements as given by Boris:
brew install cairo pango icu4c autoconf libffi libarchive libpng
export PKG_CONFIG_PATH=\
$(brew --prefix)/lib/pkgconfig:\
$(brew --prefix)/opt/libarchive/lib/pkgconfig:\
$(brew --prefix)/opt/icu4c/lib/pkgconfig:\
$(brew --prefix)/opt/libffi/lib/pkgconfig:\
$(brew --prefix)/opt/libpng/lib/pkgconfig
./configure
Note: If you already have some of the above you might rather want to run brew reinstall in place of brew install, at the risk of damaging other projects.
I didn't need to supply any flags to configure.
The aim is of course to get the training tools to compile so that combine_tessdata, wordlist2dawg, dawg2wordlist etc. are available (I haven't found macOS binaries for these anywhere).
The full instructions then become:
git clone git#github.com:tesseract-ocr/tesseract.git
git checkout tags/4.1.0
cd tesseract
./autogen.sh
brew install cairo pango icu4c autoconf libffi libarchive libpng
export PKG_CONFIG_PATH=\
$(brew --prefix)/lib/pkgconfig:\
$(brew --prefix)/opt/libarchive/lib/pkgconfig:\
$(brew --prefix)/opt/icu4c/lib/pkgconfig:\
$(brew --prefix)/opt/libffi/lib/pkgconfig:\
$(brew --prefix)/opt/libpng/lib/pkgconfig
./configure
make -j
sudo make install
# -> You should now have access to tesseract
make training
sudo make training-install
# -> You should now have access to the training tools: combine_tessdata, wordlist2dawg, dawg2wordlist, etc.
# If not, check /usr/local/bin/ is on your PATH, i.e.
export PATH=/usr/local/bin/:$PATH
Footnote: How I diagnosed the libpng problem:
As stated above and here, the error thrown is not very helpful:
make training
Need to reconfigure project, so there are no errors
Digging a little deeper, configure throws some warnings along the lines of:
configure: WARNING: pango 1.22.0 or higher is required, but was not found.
configure: WARNING: Training tools WILL NOT be built.
configure: WARNING: Try to install libpango1.0-dev package.
checking for cairo... no
configure: WARNING: Training tools WILL NOT be built because of missing cairo library.
configure: WARNING: Try to install libcairo-dev?? package.
checking that generated files are newer than configure... done
I also had one for cairo
So you have to run configure in debug mode:
./configure --enable-debug
And check config.log by greping for pango (say):
$PKG_CONFIG --exists --print-errors "pango >= 1.22.0"
That is the line that throws the warning when configure is executed.
You can now execute that last line manually:
pkg-config --exists --print-errors pango
dyld: Symbol not found: __cg_png_create_info_struct
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libPng.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Abort trap: 6
which is how I traced the libpng cause. (In my case I had to reinstall/relink libpng because of various long-running clashes associated with gnuplot/octave/aquaterm etc. etc.).
HTH someone
This is the most elegant solution to the problem I found:
brew install cairo pango icu4c autoconf libffi libarchive libpng
export PKG_CONFIG_PATH=\
$(brew --prefix)/lib/pkgconfig:\
$(brew --prefix)/opt/libarchive/lib/pkgconfig:\
$(brew --prefix)/opt/icu4c/lib/pkgconfig:\
$(brew --prefix)/opt/libffi/lib/pkgconfig:\
$(brew --prefix)/opt/libpng/lib/pkgconfig
./configure
https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00#on-macos-mojave-with-homebrew
I fixed this by copying the pkgconfig files under libffi and icu4c
(find the path by typing brew link libffi icu4c in your terminal)
and pasting them at /usr/local/lib/pkgconfig and then set
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Installing ocaml-top on OSX - GTK issue

I am trying to install ocaml-top on macOS High Sierra 10.13. I have installed homebrew (using the command given at https://brew.sh/) and done:
brew install opam
opam init
and answered Y to "Do you want Opam to modify ~/.bash_profile and ~/.ocamlinit". Then:
eval `opam config env`
opam install ocaml-top
I get the following error
The following actions failed
∗ install conf-gtksourceview 2
No changes have been performed
=-=- conf-gtksourceview.2 troobleshooting -=-=-=-=-
=> This package relies on external (system) dependencies that may be
missing.
`opam depext conf-gtksourceview.2' may help you find the correct
installation for your system.
[EDIT: trying on a second mac computer, the error is "[ERROR] The compilation of conf-gtksourceview failed at "pkg-config gtksourceview-2.0"."]
The above depext command gives:
# The following system packages are needed:
# - gtksourceview
# - libxml2
# All required OS packages found.
I have found advice (e.g. https://github.com/OCamlPro/ocaml-top/issues/46) like: "If you installed gtk+ through brew, you may need to do 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig' (homebrew)". However typing either that or "export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig" in the terminal and retrying does not help.
I do not know anything about any of this, but it looked libgtksourceview2.0-dev might be involved, so I tried
opam install libgtksourceview2.0-dev
but
[ERROR] No package named libgtksourceview2 found.
Likewise "brew install libgtksourceview2.0-dev" or "brew install libgtksourceview".
https://github.com/ocaml/opam-repository/issues/8449 seems to imply this error could be because other packages need to be upgraded, and mentions that "the expanded pkg-config --short-errors --print-errors "gtksourceview-2.0 >= 2.2.0" [...] does print more information". I have no idea what this means though and how to detect which packages need to be upgraded.
You could try
brew install pkg-config gtksourceview libxml2
Otherwise, running brew search <part-of-name-of-dep> may help to find the required dependencies.

installing usbmuxd under Mac OS X

I installed the latest version of libusb and now I'm trying to install usbmuxd.
However, it gives this error:
configure: error: Package requirements (libusb-1.0 >= 1.0.3) were not met:
No package 'libusb-1.0' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
In the installation log of libusb it says
libtool: install: /usr/bin/install -c .libs/libusb-1.0.0.dylib /usr/local/lib/libusb-1.0.0.dylib
It looks like the wrong version of the library is getting installed.
How can I solve this?
You should consider installing macports, which has usbmuxd v1.0.7 available, and then:
$ sudo port selfupdate
$ sudo port install usbmuxd
(you should de-install the libusb package you installed yourself, before doing this probably).

Resources