Error when importing XGBoost on Apple M1? - macos

Has anyone figured out how to make XGboost work with Apple M1?
I have tried multiple things to fix it, but it does not work.
I have tried reinstalling it; pip and pip3 and python -m pip and conda install; brew install limpomp; brew install gcc#8; Downloading source code and compiling locally.
It seems XGboost does not work on Apple M1.
Here is the error, this occurs when I import xgboost in my script:
XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.
Likely causes:
* OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows, libomp.dylib for Mac OSX, libgomp.so for Linux and other UNIX-like OSes). Mac OSX users: Run `brew install libomp` to install OpenMP runtime.
* You are running 32-bit Python on a 64-bit OS
Error message(s): ['dlopen(/opt/anaconda3/envs/msc-env/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n Referenced from: /opt/anaconda3/envs/msc-env/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib\n Reason: image not found']

i'd got the same issue on MacBook Pro (13-inch, M1, 2020) with chip Apple M1, fortunately after of hours of some researches i got the solution, you just follow the following instruction:
brew install libomp
conda install -c conda-forge py-xgboost

https://discuss.xgboost.ai/t/xgboost-on-apple-m1/2004/8
How to install xgboost in python on MacOS?
A combination of the answer from cherry (first) and Christoffer (second) work for me with miniforge interpreter:
Make sure gcc-11 (and g+±11) is installed, if not do so with
brew install gcc#11
brew install cmake
Then, do the following
git clone --recursive https://github.com/dmlc/xgboost
mkdir xgboost/my_build
cd xgboost/my_build
CC=gcc-11 CXX=g++-11 cmake ..
make -j4
cd ../python_package
/Users/xx/miniforge3/envs/MLEnv/bin/python setup.py install
With the path to you miniforge venv

I put Terminal in Rosetta mode first before installing brew. This way I'm essentially running intel version of the packages. I provided more details in this gist.

Related

Message "note: This error originates from a subprocess, and is likely not a problem with pip"

While downloading pip install allennlp==1.0.0 allennlp-models==1.0.0, I faced this problem:
[6 lines of output]
running bdist_wheel
running build
running build_py
running build_ext
building 'srsly.msgpack._unpacker' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for srsly
Failed to build thinc blis srsly
ERROR: Could not build wheels for srsly, which is required to install pyproject.toml-based projects
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
I have downloaded:
pip install -vvv torch
pip install numpy
pip3 install --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
and it still not working.
I am using Python 3.10.2 on Windows 11 Pro.
What should I do?
I had Python 3.10 and had the same error installing psutil from pip. I fixed the problem by installing an older version of pip using the command:
pip install pip==21.3.1
You have to install the Python 3.9.10 version from python.org and after installation, upgrade your pip and everything will be sorted.
It is the problem in Python 3.10.2... This method is working. I was suffering from the same problem in installing the turtle, so I did that and error was solved.
This particular error is caused by not having a C/C++ compiler installed. As said in the error message, either install MSVC or another compiler to compile it.
Please read your error messages; they are there for a reason.
If you're using a Python 3 image, this might help:
RUN apk update
RUN apk add make automake gcc g++ subversion python3-dev
Reference from Problems with pip install numpy - RuntimeError: Broken toolchain: cannot link a simple C program
https://visualstudio.microsoft.com/visual-cpp-build-tools/
Download and install or update
Microsoft Visual C++ 14.0 or greater is required.
You must be install build visual tools 15, 17, 19, or greater.
Download from Microsoft C++ Build Tools.
To solve this problem, you need to download Visual Studio from its main page.
If Visual Studio is already installed, then when you run the installer, you can modify it (by clicking the modify button):
During Visual Studio installation (or installation modification) choose Desktop Development with C++:
First: You installed the Mingw-w64 compiler with a full MSYS2 package, and this package included Python.
Second: you get the error because the plugin is not in the Python packages installed by MSYS2.
So: uninstall MSYS2 and install a minimalistic MinGW (MinGW - minimalistic GNU for Windows).
And finally Install a version of Python from the official Python page.
Now if you can install plugins.
I've found a similar question from GitHub, and credits goes to thaibee. Here I quote:
It's a problem with Microsoft products and is
very easy to solve.
If you can't install these plugins as well,
need to download it from other repositories like this one:
https://www.lfd.uci.edu/~gohlke/pythonlibs/ depends on the version of python and the system.
For example: for my Windows 11 (x64) and Python 3.10 I took this file: pyodbc‑4.0.32‑cp310‑cp310‑win_amd64.whl
It's very easy to install: pip install pyodbc‑4.0.32‑cp310‑cp310‑win_amd64.whl
After it, the system works well and didn't ask you about VC.
This solution I found in problem with the MySQL plugin for Django. I don't understand why - but they also use VC for the installation process.
I understand your problem, and I have faced it too. I tried multiple solutions, but it didn't work, so I simply uninstalled my Python and installed some older version of it. Example: I recently uninstalled Python 3.10.2 and installed 3.9.10.
It worked without any errors.
I had a similar problem while installing with pip3: building wheel for box2d-py (setup.py) ... error
The solution was just to install SWIG prior to box2d, so I added the following steps manually:
pip install swig
pip install gym[box2d]
For Mac, there is a possible workaround for this problem if you use Conda. The idea is to create an x86 environment on the Mac and do your pip install after that.
conda create -n <name>
conda activate <name>
conda config --env --set subdir osx-64
conda install python=3.8
Here I choose Python 3.8, but you can choose another version.
If you are on macOS (maybe Apple silicon) then first try to do this from your base location of the terminal:
eval "$(/opt/homebrew/bin/brew shellenv)"
Then, do brew update and brew upgrade.
Once you are done with that, type
brew install geos
Now again go to your virtual environment and activate it (if you are working in the virtualenv) and then type:
python3.10 -m pip3 install [module name]
I was facing the same problem when executing:
python -m pip install package-name
After many failed tentatives, what fixed the problem for me was executing:
py -m pip install package-name
When I type py in the terminal, it shows this information:
Python 3.9.8 (tags/v3.9.8:bb3fdcf, Nov 5 2021, 20:48:33) [MSC v.1929 64 bit (AMD64)] on win32
When I type python in the terminal, it shows this information:
Python 3.8.2 (default, Apr 9 2020, 13:17:39) [GCC 9.3.0 64 bit (AMD64)] on win32
I believe that this problem is related to the Python interpreter version.
I tried all recommendations that were written, but none worked. My Python was 3.11.
So I just installed Python 3.8.10 from here:
https://www.python.org/downloads/release/python-3810/
And ran
C:\Python38\python.exe -m pip install matplotlib
And it worked.
I faced a similar problem while installing pandas-datareader.
I was using Python 3.11.0, and after trying all possible solutions, I downloaded Python 9.10.0 and it worked fine.
We can install DVC with the below commands:
conda install -c conda-forge mamba # installs much faster than conda
mamba install -c conda-forge dvc
For more information please refer this: https://dvc.org/doc/install/

Installing xv6 on a macOSX 10.15

I've been trying to install xv6 on my macOSX through terminal.
I used the command brew install qemu to install qemu and have hit the codes:
sudo port install i386-elf-gcc
and after modifying the Makefile from i386-jos-elf to i386-elf- I'm receiving the following message on trying to run xv6 when I hit the code:
cd xv6-public
make
the following message:
Error: Couldn't find an i386--elf version of GCC/binutils.
Is the directory with i386-jos-elf-gcc in your PATH?
If your i386--elf toolchain is installed with a command
prefix other than 'i386-jos-elf-', set your TOOLPREFIX
environment variable to that prefix and run 'make' again.
To turn off this error, run 'gmake TOOLPREFIX= ...'.
gcc -m32 -gdwarf-2 -Wa,-divide -c -o usys.o usys.S
Any help would be greatly appreciated.
Maybe the xv6 version you downloaded is out of date. I also encountered this problem today. After updating to the latest version, it can be successfully compiled.
The version downloaded with this command seems to be more advanced.
git clone git://github.com/mit-pdos/xv6-riscv-fall19.git
You can try this tutorial. I succeeded by his method today.
This is the tutorial but written in Chinese
Installing pre-requisite libraries
brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat
Installing the RISC-V GNU toolchain
brew tap riscv/riscv
brew install riscv-tools
path=(/usr/local/opt/riscv-gnu-toolchain/bin ${path})
Installing QEMU
brew install qemu
Installing xv6
git clone --depth 1 --single-branch \
https://github.com/mit-pdos/xv6-riscv.git \
./xv6
Running xv6:
cd ./xv6
make qemu

Installing PySide on Mac: is there a working method?

I may be doing something wrong, but I have been trying to install pyside on Mac 10.12 (Sierra). Here is what I tried (after installing Qt with brew):
With the precompiled package (1.2.1); fails because of "incompatible package".
With sudo -H pip install pyside (1.2.4): fails with the following error:
Qt QTGUI library not found.
Qt QTXML library not found.
Qt QTCORE library not found.
CMake Error at ApiExtractor/CMakeLists.txt:82 (qt4_add_resources):
Unknown CMake command "qt4_add_resources".
With brew install pyside==1.2.2 : works successfully but when calling it from a python program, fails with ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Libmrary not loaded: libpyside-python2.7.1.2.dylib
Referenced from: /Library/Python/2.7/site-packages/PySide/QtCore.so
Reason: unsafe use of relative rpath libpyside-python2.7.1.2.dylib in /Library/Python/2.7/site-packages/PySide/QtCore.so with restricted binary
The last one did offer some hope, and I tried PySide import error Mac OS X El Capitan, Library not loaded: #rpath/libpyside.cpython-34m.1.2.dylib . Unfortunately, the explanation was quite elliptic and I ended up breaking things further.
Am I missing something obvious? The fact that the precompiled packages are old and the web doc is not updated, that brew install does not seem to work (and the documentation makes no mention of it) and generally number of questions asked about pyside and the technical complication of the answers do not seem very good signs.
Does someone know what the matter is with PySide's installation on Mac OS, technically? What's the best solution in my particular case?
More generally, is there hope for improvement with PySide on Mac?
Update (25 Jan 2017): Workaround?
Since we are waiting for an update from Pyside, is someone willing to take the challenge of installing 1.2.2 on OS Sierra with brew, and resolve the "unsafe use of relative path"? Perhaps propose a step-by-step tutorial?
That might save the day for PySide on Mac... while relieving the time pressure on the Pyside development team?
I have MAC osSierra (10.12.6). I needed to install PySide 1.2.4 for Python 3.3.6. I did the following to build and install PySide 1.2.4 that I need. You can do the following for any Python 3.3.x, I guess.
I am a newbie to Mac and Python. Please ignore if I have any mistakes.
Install pyenv
brew install pyenv
Install Python 3.3.6 using pyenv
pyenv install 3.3.6
Add python 3.3.6 into system path
PATH="/Users/myname/.pyenv/versions/3.3.6/bin:${PATH}"
export PATH
Install Xcode from app store, then run the following. Xcode download and install took 30-40 minutes for me.
xcode-select --install
sudo xcodebuild -license
Install cmake
brew install cmake
Verify cmake is installed. I see version 3.10.0 installed
cmake —version
Tap qt4. Note: I tried qt5, but pyside build is not working for me with qt5.
brew tap cartr/qt4
brew tap-pin cart/qt4
Install qt#4.
brew install qt#4
Verify qmake is installed. I see version 2.01a installed
qmake —version
(If qmake is not recognized, create links to it using below command)
brew link cartr/qt4/qt#4 —-force
If you are using “PySide.QtWebKit” in your programs, you need to install qt-webkit. Install pyside (1.2.2 ??), which will install qt-webkit. I am not sure if qt-webkit can be installed directly, if so someone can correct me.
brew install pyside
Download PySide 1.2.4 tar file.
wget https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz
Untar the tar file
tar -xvf PySide-1.2.4.tar.gz
Go into the folder
cd PySide-1.2.4
Build pyside. This build step took almost 30-40 minutes for me
python setup.py bdist_wheel
Verify that “dist” folder is created and it has pyside wheel file in it.
Go into the “dist” folder
cd dist
Instal PySide, last step!!
pip install PySide-1.2.4-cp33-cp33m-macosx_10_12_x86_64.whl
Congratulations!, now you have PySide 1.2.4 for Python 3.3.x
This isn't the answer but unfortunately there has not been any output from pyside team for macOS sierra .Only supported OS from apple are
10.6 Snow LeopardOS X
10.7 LionOS X
10.8 Mountain LionOS X
10.9 MavericksOS X
10.10 Yosemite
Update : (You can try this still )
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/fdfc724dd532345f5c6cdf47dc43e99654e6a5fd/Formula/qt5.rb
brew install ./qt5.rb
If above lines doesn't work :
You’ll need the Xcode commandline tools:
xcode-select --install sudo xcodebuild -license
Then the following packages can be easily installed via brew:
brew install qt5 cmake libxslt libxml2
This will install Qt 5.6.1-1 and cmake 3.5.2 your system
Now time to clone ! Not from github but from this link :
So Clone the pyside-setup repository and have it also pull down its gitmodules:
git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup
This command worked fine for people using Python 2.7.11 and Python 3.5.1. Remember to have pip installed with the wheel package or you’ll get an error about bdist_wheel.
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt5/5.6.1-1/bin/qmake --cmake=/usr/local/bin/cmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin
(Note :
The exact paths given in the arguments may not be identical on your system so verify those prior to compiling)
Install the wheel :
A wheel was hopefully built in the dist folder. So just cd dist and pip install away!
Notes on pre-compiled wheels
Unfortunately, and like with PySide, these wheels are not “portable” and won’t install on systems which doesn’t already have the specific Qt5 version installed used during compilation. This, I believe, is because PySide2 links dynamically (instead of statically) against the Qt5 installation. Hopefully, this is something The Qt Company will address via official PySide2 wheels, as Riverbank Software is now providing a fully portable PyQt5 wheel for Python 3 which is absolutely awesome.
New Repository (not from github)
Reference
The Mac steps from here worked for me: https://fredrikaverpil.github.io/2016/08/17/compiling-pyside2/
You’ll need the Xcode commandline tools:
xcode-select --install
sudo xcodebuild -license
Then the following packages, easily installed via brew:
brew install qt5 cmake libxslt libxml2
Clone the pyside-setup repository and have it also pull down its gitmodules:
git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup
Build it. This command worked fine for me using Python 2.7.11 and Python 3.5.1. Remember to have pip installed with the wheel package or you’ll get an error about bdist_wheel.
cd pyside-setup
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt5/5.6.1-1/bin/qmake --cmake=/usr/local/bin/cmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin
Last but not least, install the wheel:
cd dist
pip install PySide2-2.0.0.dev0-cp27-cp27m-macosx_10_12_x86_64.whl
All credits go to Fredrik Averpil's wonderful post.
You need a specific version of Qt and pyside.
Install both the QT 4.8.5 package as well as pyside from the Mac installers on the page below:
https://wiki.qt.io/PySide_Binaries_MacOSX
You need QT4 to install PySide on 10.11 (not sure about 10.12).
Install QT5 either via Brew or via installer, get cmake via brew and get the latest PySide source (https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz) Run the following to get Qt4:
brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt_4
Once you do so; cd in the source folder and run the following to build:
python setup.py bdist_wheel --ignore-git --qmake=[QMAKE_FROM_QT4_PATH] --cmake=[YOUR_CMAKE_PATH]
cd dist
pip install [YOUR_BUILT_PYSIDE_WHEEL]
Once you do so, you can check that PySide is working correctly, opening a Python console and typing import PySide
I still not have a solution, but I found an alternative.
First of all, I am not an expert (I am super new coding). Based on my own experience below you will find a solution as well.
I need to clarify something first, there are two ways to use this GUI QT - PyQt by Riverbank Computing or(and) PySide, originally developed by Nokia.
I tried many differents ways to install PySide on my MacOS Sierra version10.12.5, but no success, so I ended up finding PyQt, that does the same thing.
Watching this video I installed the PyQT5 in my Mac OS and now it is working. https://www.youtube.com/watch?v=2kHk8ZjxH64
Example of Hello World using PyQT http://pythoncentral.io/intro-to-pysidepyqt-basic-widgets-and-hello-world/
The wiki.qt.io says "PySide has included support for Python 3.2 since version 1.0.8." but it doesn't work for me.
Good lucky.

updating octave: linking the installation

I have OSX 10.10.5 with Octave 3.4.0 running (installed, who knows how, I did it a million different ways through port, file extraction, ftp, homebrew…). I tried to update my Programme (brew install octave or sudo port install octave) and Terminal spits out:
Warning: octave-3.8.2 already installed, it's just not linked
Okay, great. So I have a better programme somewhere installed. What now? How on earth am I supposed to “just link” the newer installation?
If you install octave with Homebrew and it doesn't link it it should tell you why. You can force Homebrew to link octave with
$ brew link --overwrite octave
You can also add the --dry-run option to check and see what Homebrew will do to link octave
$ brew link --overwrite --dry-run octave
A possible reason for Homebrew not linking octave is that you've installed it by another method, MacPorts for instance. It is not recommended that you use both Homebrew and MacPorts on the same system.

Install Zathura on macOS 10.10.2

I am trying to install Zathura on a Mac OS X 10.10.2. I have downloaded Zathura 0.3.2 and tried to run make but it requires girara. Girara requires gtk 3.2 but brew install gtk+3 only installs 3.14.
Does anyone know a set of procedures to install Zathura?
Since this question and answer is about 6 years old, here's a current method for Big Sur as of writing (expanding on my edit of this answer on Ask Different).
I originally tried to compile it using the suggested method in the documentation which is this MacPorts port. Although it compiles, it gives the error Gtk-WARNING **: cannot open display when running. There are fixes for other ports of programs with the same error but instead, I found a Homebrew tap which installs it without issues.
To install:
brew tap zegervdv/zathura
brew install zathura
brew install zathura-pdf-mupdf
mkdir -p $(brew --prefix zathura)/lib/zathura
ln -s $(brew --prefix zathura-pdf-mupdf)/libpdf-mupdf.dylib $(brew --prefix zathura)/lib/zathura/libpdf-mupdf.dylib
There is work to integrate the program better into macOS but it's still in development - see here.
I solved the problem by adding the adding the following to my $PKG_CONFIG_PATH:
export $PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/Cellar/zlib/1.2.8/lib/pkgconfig:/usr/local/Library/ENV/pkgconfig/10.10
I could then make and make install without any problems.

Resources