Issues with scikit-bio on Mac M1 - skbio

I tried installing scikit-bio by running conda install -c https://conda.anaconda.org/biocore scikit-bio per the documentation, but verifying the installation via python -m skbio.test yielded the following error: Error while finding module specification for 'skbio.test' (ModuleNotFoundError: No module named 'skbio').
Next, I tried installing with pip install numpy and pip install scikit-bio, but that yielded a huge wall of errors. Tried the installation test anyway, got the same ModuleNotFoundError.
I'm on a MacBook Air 2020 with a M1 processor, so not sure if that's causing the issue.

I don't know if you still have problems with scikit-bio but the solution that worked for me was using sse2neon package: https://github.com/DLTcollab/sse2neon
Following instructions should work
git clone https://github.com/biocore/scikit-bio
cd scikit-bio
wget https://github.com/DLTcollab/sse2neon/blob/master/sse2neon.h
Open the simde-sse2.h file and replace each of the following two lines:
#include <xmmintrin.h>
#include <emmintrin.h>
with:
#include "sse2neon.h"
then run:
pip install .
!Note that this solution doesn't work for newer python releases. I used python 3.8 for this solution.

Related

Can't install kivy. Fail Building wheel for kivy (pyproject.toml)

I've somehow screwed up either my pip or my kivy files. I cant install either. I've tried pip install kivy and also git clone https://github.com/kivymd/KivyMD.git --depth 1
I'm on a macos Monterey 12.6.1
python 3.11`
I start with:
$ python3 -m venv venv
$ . venv/bin/activate
$ pip install kivy
It gets hung up on the building wheel for kivy pyproject.toml.
Requirement already satisfied: certifi>=2017.4.17 in ./myvenv/lib/python3.11/site-packages (from requests->Kivy-Garden>=0.1.4->kivy) (2022.9.24)
Building wheels for collected packages: kivy
Building wheel for kivy (pyproject.toml) ... -
Then the end of the error code looks like:
kivy/core/image/img_imageio.c:438:62: note: expanded from macro '__Pyx_PyFrame_SetLineNumber'
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
~~~~~~~^
/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/pytypedefs.h:22:16: note: forward declaration of 'struct _frame'
typedef struct _frame PyFrameObject;
^
2 warnings and 1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for kivy
Failed to build kivy
ERROR: Could not build wheels for kivy, which is required to install pyproject.toml-based projects
(
I'm at a complete lost. I've tried to uninstall and reinstall packages, I've done pip install wheel , and pip install clang both recommended from other SO posts.
I had the same problem so I asked on the Kivy Discord and I was told that there is no wheel for kivy on Python 3.11 yet.
I was told to build it from source and that worked.
https://kivy.org/doc/stable/gettingstarted/installation.html#kivy-source-install
git clone https://github.com/kivy/kivy.git
cd kivy
python3.11 -m pip install cython
python3.11 setup.py build_ext --inplace
make install
It is best to do this in a virtual environment
python3.11 -m virtualenv <Environment Name>
cd <Environment Name>
source bin/activate
Right now, February 2023, there are two alternatives to this problem in macOS. Possibly works the same for Windows, I don't know. The first is shown above and can be described as "building your own wheel" for Python 3.11. That approach did not work for me as my installation crashed at the "make install" line with error messages about xcode. The second alternative, which worked for me, was to install the most recent version of Python for which Kivy already had a wheel buuilt. In my case, I installed Python3.10. After i installed Python3.10, the Kivy installtion instructions at www.kivy.org worked flawlessly.
Python 3.10 has a installer package at www.python.org so its easy to install. In my case, the installer package modified my .bash_profile file so that python3.10 was inserted into my PATH.
In my case, Python3.10 was the most recent version of Python installed on my machine. If Python 3.10 is not the most recent version on your computer, then you may encounter problems. Different applications on your computer may use different releases of Python. The Python installer may change your PATH variables to point only at the Python 3.10 installation.
I suspect that the "build your own wheel" issue is common with Kivy installtions because Kivy always lags behind Python. Python will release Python 3.12 and it will be a while, months I would guess, before Kivy catches up. So that means if you keep your Python install always up-to-date then you will center encounter the need to "build your own wheel".

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/

Installation problem with PyTorch's Geometric. "torch-scatter" produces an error with exit status 1

Could anyone if used PyTorch geometric before, help me resolve this issue. I'm having trouble installing torch-scatter from PyTorch Geometric to deal with some tabular data for question answering task based on TAPAS model. I presume there is a compile error at source. I tried checking other forums and found no solution for this yet.
Procedure followed to produce the error:
pip3 install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install torch-scatter
Console output:
ERROR: Command errored out with exit status 1:
I also tried using the python -f flag and specifically tried to pull from the source at:
pip3 install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.1+cpu.html
Following are my PyTorch and CUDA versions with the respective imports and console outputs:
python -c "import torch; print(torch.__version__)"
Output:
1.8.1+cpu
CUDA version:
python -c "import torch; print(torch.version.cuda)"
Output:
None
Python version:
Python 3.7.5
Thank you very much for your time and guidance.
Solution found:
The error is due to wrong/unsupported GCC versions (that's indeed more PyTorch related). I tried installing from binaries which couldn't find compatible version. After some research, I found that Pytorch geometric installation documentation suggests that only PyTorch versions 1.4.0, 1.5.0, 1.6.0, 1.7.0, and 1.8.0 are compatible, but does not explicitly mentions this.
Following solution worked:
Downgrading PyTorch to any of the above versions solved the issue. Make sure that you use the same version of PyTorch and torch-scatter while installation. In my case, 1.8.0
I had this problem too which is solved by install C++ build tools. You can install it from vs_buildtools.exe that is downloadable here
I also had some issues related to the torch_geometric, and I resolved those issues after some research. Following are the solutions that I have applied:
After installing torch, please install the following libs:
1. torch-scatter
2. torch-sparse
3. torch-cluster
Then install torch-geometric.
You can install the above packages using pip command (pip install ), If it does not work install through HTML link by selecting your specific version.
Command: pip install libname -f link
Example: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0%2Bcpu.html
For my case, I have used the torch 1.12 and install the above packages from the above link.
Thanks

GPU driver and CUDA is not enabled and accessible by PyTorch on MacOS

GPU driver and CUDA is not enabled and accessible by PyTorch.
torch.cuda.is_available() returns false
I am using macOS Mojave 10.14.6
I have installed Cuda 10.0 version of pytorch.
I tried verfication on https://pytorch.org/get-started/locally/ and constructing a randomly initialized tensor works just fine.
But when I tried
import torch
torch.cuda.is_availalbe()
it returns false.
Therefore, I followed instructions on Pytorch and installed Anaconda and Cuda.
Then tried this:
git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
In terminal, I got
fatal error: 'string.h' file not found
#include_next <string.h>
I searched on stackoverflow and came up with this. Build Pytorch from source . So I tried:
$ find /Library/Developer/CommandLineTools/usr -type f -name string.h
which returned /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h
Doesn't this mean I already have string.h?
How can I solve this problem?
Are you installing from a conda env? According to the github this should work:
- Create a conda env
- conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing (that installs some requirements)
Then this (which I assume you've already done):
git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive
And finally set up the conda variable and install:
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
There are issues on the git reporting that behavior here which suggest to add something like:
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ NO_CUDA=1 python setup.py install
Check thatNO_CUDA, this issue as also been mentioned HERE in the forums and it seems to be that it could be an issue caused by the OS and driver versions. If that should be the case I recommend to use Nvidia Docker (hopefully it has mac support) with a pytorch container from https://ngc.nvidia.com/catalog/landing
It that should also fail, your best bet is to install without CUDA support.

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.

Resources