I download a not commonly-used software package in github in Mac M1. I am trying to compile and install myself according to the instruction.
I have encountered the following problem saying "command/usr/bin/clang with exits error 1". I did install xcode in my mac. Because the built-in gcc version is 4.2, I upgrade the version using brew install gcc#7 command and the link to this gcc version. But I still face the same compiling problem.
Does anyone have instructions for me how to solve this? The author did not maintain the source code anymore and I have struggled for one day and still can not fix the problem.
The follow steps worked!
upgrade pip and related components by:
python -m pip install --upgrade pip
pip install –upgrade wheel
pip install –upgrade setuptools
install openssl
brew install openssl re2
reinstall your package with some environment to be set
LDFLAGS="-L$(/opt/homebrew/bin/brew --prefix openssl)/lib -L$(/opt/homebrew/bin/brew --prefix re2)/lib" CPPFLAGS="-I$(/opt/homebrew/bin/brew --prefix openssl)/include -I$(/opt/homebrew/bin/brew --prefix re2)/include" GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install <your package name>
Source: https://candid.technology/error-command-usr-bin-clang-failed-with-exit-code-1/
so I've been trying different methods to install TA-Lib, and found several different methods to install it, none of which have been easy, but even when TA-Lib is installed and appears on pip list, and even managed to install it on pipenv virtual environment, however if I actually want to go ahead and use it by typing
import talib
I get the following error:
ImportError: 2): Symbol not found: _TA_ACOS Referenced from: /Users/teo/.local/share/virtualenvs/trendingcoin-nriNAUCq/lib/python3.8/site-packages/talib/_ta_lib.cpython-38-darwin.so Expected in: flat namespace in /Users/teo/.local/share/virtualenvs/trendingcoin-nriNAUCq/lib/python3.8/site-packages/talib/_ta_lib.cpython-38-darwin.so
Now I would like you to know that I have tried many different methods to install it, they are detailed in this thread: Is it enough to install TA-Lib on Brew to use it? Pip throws me an error
As a wanna-be technical analyst, it would be sad if I can't use the infamous TA-Lib.
I was able to make it work following some of the steps in this github issue: https://github.com/mrjbq7/ta-lib/issues/381
$ arch -x86_64 brew install python#3.9
$ arch -x86_64 brew install ta-lib
$ arch -x86_64 brew link ta-lib
$ arch -x86_64 python3.9 -m pip install --no-cache-dir ta-lib
You'll need x86/brew and rosetta: https://stackoverflow.com/a/64997047/3090309
NOTE: In my case, I went though so many intents, that really made the difference to include the --no-cache-dir option.
The solution here seems to work:
https://github.com/mrjbq7/ta-lib/issues/408#issuecomment-839583759
$ conda install -c conda-forge ta-lib
Install ta-lib
brew install ta-lib
Find pip command for your environment
which -a pip
/home/<user>/.conda/envs/newenv/bin/pip <---------------
/usr/bin/pip
Install ta-lib wrapper via pip command
/home/<user>/.conda/envs/newenv/bin/pip install ta-lib
Here's what I did with my Mac M1:
# install python3.10
arch -arm64 brew install ta-lib
export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include"
export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib"
arch -arm64 python -m pip install --no-cache-dir ta-lib
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using
python3 -m pip install scipy
I also tried installing everything from brew, and import scipy works, but using it gives a seg fault. I have installed ARM versions of lapack and openblas, but this does not fix the problem.
Has anyone succeeded? (I am interested in running it natively, not through Rosetta).
It's possible to install on regular arm64 brew python, you need to compile it yourself.
If numpy is already installed (from wheels) you'll need to uninstall it:
pip3 uninstall -y numpy pythran
I had to compile numpy, which requires cython and pybind11:
pip3 install cython pybind11
Then numpy can be compiled:
pip3 install --no-binary :all: --no-use-pep517 numpy
Scipy needs pythran (this should happen after installing numpy):
pip3 install pythran
Then we need to compile scipy itself, it depends on fortran and BLAS/LACK:
brew install openblas gfortran
Tell scipy where it can find this library:
export OPENBLAS=/opt/homebrew/opt/openblas/lib/
Then finally compilescipy:
pip3 install --no-binary :all: --no-use-pep517 scipy
This one worked for me after wasting hours:
pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy
This solution worked on my M1 machine with pyenv:
brew install openblas
OPENBLAS="$(brew --prefix openblas)" pip install numpy scipy
You can install miniforge from https://github.com/conda-forge/miniforge#miniforge3
and then install those packages with,
conda install numpy scipy matplotlib
For me the easiest solutions:
brew install scipy
Probably good idea to edit the PATH, so the homebrew version will be the default.
I managed to get scipy installed on Apple Silicon. I mostly followed the instructions by lutzroeder here: https://github.com/scipy/scipy/issues/13409
Those instructions weren't successful for me, but running 'pip3 install scipy' worked afterwards. I think this fixed the problem for me:
/opt/homebrew/bin/brew install openblas
export OPENBLAS=$(/opt/homebrew/bin/brew --prefix openblas)
export CFLAGS="-falign-functions=8 ${CFLAGS}"
For those who need it for short-term purposes and don't want too much hustle - it seems to work with python 3.6.4 and scipy 1.5.4 out of the box (Big Sur 11.5.2, M1 chip).
In addition, if someone has this error message>
########### CLIB COMPILER OPTIMIZATION ###########
Platform :
Architecture: aarch64
Compiler : clang
CPU baseline :
Requested : 'min'
Enabled : none
Flags : none
Extra checks: none
CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : none
Generated : none
CCompilerOpt.cache_flush[809] : write cache to path
I found this solution before compile numpy and scipy
Analysis of reasons:
From the above error message, you can see that the last error shows that clang has an error, so it is speculated that it should be an error caused by the compiler, because the new version of the xcode command tool uses the arm version of the compilation method by default, and if we want to use For x86 architecture, we need to manually set the specific architecture through environment variables.
export ARCHFLAGS="-arch x86_64"
example:
3c790c45799ec8c598753ebb22/build/temp.macosx-10.14.6-arm64-3.8/ccompiler_opt_cache_clib.py
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/daniel_edu/Projects/PERSONAL/great_expectation_demo/.env/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/c_b9kh2x1px7vl5683rwz8fr0000gn/T/pip-install-y8alaej_/numpy_3d813a3c790c45799ec8c598753ebb22/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/c_b9kh2x1px7vl5683rwz8fr0000gn/T/pip-install-y8alaej_/numpy_3d813a3c790c45799ec8c598753ebb22/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/zb/c_b9kh2x1px7vl5683rwz8fr0000gn/T/pip-record-q9vraevr/install-record.txt --single-version-externally-managed --compile --install-headers /Users/daniel_edu/Projects/PERSONAL/great_expectation_demo/.env/include/site/python3.8/numpy Check the logs for full command output.
(.env) ➜ great_expectation_demo git:(master) ✗ export ARCHFLAGS="-arch x86_64"
(.env) ➜ great_expectation_demo git:(master) ✗ pip install --no-binary :all: --no-use-pep517 numpy
Collecting numpy
Using cached numpy-1.21.5.zip (10.7 MB)
Preparing metadata (setup.py) ... done
Skipping wheel build for numpy, due to binaries being disabled for it.
Installing collected packages: numpy
Running setup.py install for numpy ... done
Successfully installed numpy-1.21.5
What version of scipy you're trying to install?
To me running on Macbook air M1, I needed to increase the version from scipy==1.5.1 to scipy==1.7.3, so I guess you should use 1.7.3 version or above it and all will be fine...
pip install -Iv scipy==1.7.3
Or just add in your file requirements.txt this line:
scipy==1.7.3
The following worked for me.
I'm currently using Python 3.10.8, installed using brew.
And currently, when installing numpy==1.23.4, setuptools < 60.0.0 is required.
I'm using (brew --prefix)/bin/python3 -m pip for explicitly calling the pip from python 3.10 installed by brew.
Here are the versions I've just installed.
# python 3.10.8
# pip 22.3
# setuptools 59.8.0
# wheel 0.37.1
# numpy 1.23.4
# scipy 1.9.3
# pandas 1.5.1
# scikit-learn 1.1.3
# seaborn 0.12.1
# statsmodels 0.13.2
# gcc 12.2.0
# openblas 0.3.21
# gfortran 12
# pybind11 2.10.0
# Cython 0.29.32
# pythran 0.12.0
Here are the steps I followed:
# setuptools < 60.0.0 is required for numpy==1.23.4 in Python 3.10.8
$(brew --prefix)/bin/python3 -m pip install --upgrade pip==22.3 setuptools==59.8.0 wheel==0.37.1
# uninstall numpy and pythran first
$(brew --prefix)/bin/python3 -m pip uninstall -y numpy pythran
# uninstall scipy
$(brew --prefix)/bin/python3 -m pip uninstall -y scipy
# install prerequisites (with brew)
brew install gcc
brew install openblas
brew install gfortran
# set environment variables for compilers to find openblas
export LDFLAGS="-L/opt/homebrew/opt/openblas/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openblas/include"
# install the prerequisites (with pip)
$(brew --prefix)/bin/python3 -m pip install pybind11
$(brew --prefix)/bin/python3 -m pip install Cython
# install numpy
$(brew --prefix)/bin/python3 -m pip install --no-binary :all: numpy
# install pythran after installing numpy, before installing scipy
$(brew --prefix)/bin/python3 -m pip install pythran
# install scipy
export OPENBLAS="$(brew --prefix)/opt/openblas/lib/"
$(brew --prefix)/bin/python3 -m pip install scipy
# install pandas
$(brew --prefix)/bin/python3 -m pip install pandas
# install scikit-learn
$(brew --prefix)/bin/python3 -m pip install scikit-learn
# install seaborn
$(brew --prefix)/bin/python3 -m pip install seaborn
# install statsmodels
$(brew --prefix)/bin/python3 -m pip install statsmodels
I use conda install scipy to resolve this problem. Conda have a custom version of scipy for Apple M1. Update macOS to 12 if you don't want to use Conda.
According to this Github issue, Scipy doesn't work on MacOS 11 (Big Sur). If none of these solutions are working for you I'd suggest updating your OS.
SciPy maintainer here.
SciPy is now distributed for M1, on both conda and pip. You need at least macOS 12.0 (Monterey) and Python >= 3.8. Our support for macOS is good, meaning you should not need to do anything special or compile yourself unless you want to use a development version or older macOS versions.
If you need to compile, only use our guides (e.g. https://scipy.github.io/devdocs/dev/contributor/building.html#building-from-sources). There are tons of moving pieces and doing something else might work today, but not tomorrow.
Avoid using pip to compile SciPy. Use our developer script python dev.py build after having followed the guides I linked to setup system dependencies for your platform.
Do NOT use brew to install a Python package, use an environment. brew is great to install system dependencies or other dev tools, but should not be used to install Python packages. Down the road this is a recipe for trouble.
I have the same problem.
pyhton(3.9.1).
using virtual environmnet (venv).
installed django.
updated:
setuptools: pip install --upgrade setuptools,
pip(20.3.3): py -m pip install --upgrade pip
wheel: python -m pip install --upgrade pip setuptools wheel
(latesed version for today(30/12/20)).
Tried to use: python -m pip install -U channels.
installed "Microsoft Visual C++ Build Tools"
Tried the self installing twisted: https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted
All done, but still not working.
Also tried pip install:
pip install pytype
pip install django-channels.
The django-channels, but when runnig on PyCharm, it recognize channels but not: channels.layers.
Can anyone help?
I managed to install it:
just removed python, and installed instead Anaconda 3.
I wanted to run python file. But I could check this error when I ran it.
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
My system is Mac os 10.13.2 and I used python 2.7
Looks like something went wrong with pycurl/openssl, try this:
pip uninstall pycurl
pip install --compile --install-option="--with-openssl" pycurl
if still fails, try this as well
brew reinstall openssl
This was done by my fellow mac users.
# pycurl
pip uninstall pycurl
export CPPFLAGS=-I/usr/local/opt/openssl/include # may be needed
export LDFLAGS=-L/usr/local/opt/openssl/lib # may be needed
pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl
I got this same issue in windows which had a different fix(perhaps this might fit Mac too). In my requirements.txt I had pycurl-7.43.0.4 but on the windows dowloader page I could only find 7.44.1 which I installed (pip install .\pycurl-7.44.1-cp37-cp37m-win_amd64.whl). And then on starting my Django server python manage.py runserver I got the error in question. And the solution was to bring the pycurl back to it's expected version. pip install pycurl==7.43.0.5 and it replaced the version as given below. And the error was gone!
For m1 users, it works for me
brew install curl-openssl
pip uninstall pycurl
PYCURL_SSL_LIBRARY=openssl \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
CPPFLAGS="-I$(brew --prefix openssl)/include"
pip install --compile --install-option="--with-openssl" pycurl
Reinstall the curl libraries
brew install curl --with-openssl
Install pycurl with correct environment and paths
export PYCURL_SSL_LIBRARY=openssl
pip uninstall pycurl
pip install --no-cache-dir --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" pycurl
How I resolve this issue on my Mac Book Pro M1 (Chip Apple M1 Pro).
I am using system provided Python 3.9.6 as MacOs Monterey 12.6 completely removed Python 2.7 and providing Python 3.9.6 as system Python.
two thing is very important to know curl info by using
curl-config --features
brew openssl info
this gives you information according to your own machine setup for using in below installation to use.
In my case it was
export LDFLAGS="-L/opt/homebrew/opt/openssl#3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl#3/include"
For pkg-config to find openssl#3 you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl#3/lib/pkgconfig"
pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl
it was done!!! perfectly.
On macOS Catalina (v10.15.6), make sure you uninstall previous curl then install curl-openssl as well as exporting variables so compiler can find them:
brew uninstall curl
brew install curl-openssl
export PYCURL_SSL_LIBRARY=openssl
export PYCURL_CURL_CONFIG=/usr/local/opt/curl-openssl/bin/curl-config;export LDFLAGS='-L/usr/local/opt/openssl/lib -L/usr/local/opt/c-ares/lib -L/usr/local/opt/nghttp2/lib -L/usr/local/opt/libmetalink/lib -L/usr/local/opt/rtmpdump/lib -L/usr/local/opt/libssh2/lib -L/usr/local/opt/openldap/lib -L/usr/local/opt/brotli/lib';export CPPFLAGS=-I/usr/local/opt/openssl/include;pip install pycurl --compile --no-cache-dir
pip install pycurl
I am running MacOS Ventura on my MacBook Pro.
We use Python 3.7. The following worked for me:
% python3.7 -m pip uninstall pycurl
% brew install curl
% brew install openssl
% export LDFLAGS="-L/usr/local/opt/curl/lib $LDFLAGS"
% export CPPFLAGS="-I/usr/local/opt/curl/include $CPPFLAGS"
% export PKG_CONFIG_PATH=/usr/local/opt/curl/lib/pkgconfig
% python3.7 -m pip install pycurl==7.45.2 --no-cache-dir --compile --ignore-installed --install-option="--openssl-dir=/usr/local/opt/openssl#3/"