How to install SciPy on MacOS with M1 - python

I am trying to install keras in a virtual env but was getting errors. I then tried to install it following the steps on this site: https://www.tutorialspoint.com/keras/keras_installation.htm. The first few installs work but when I ran pip install SciPy I kept getting errors. I found others have encountered issues with installing SciPy on apple silicon online and saw a few recommendations but haven't been able to get anything to work so far. Can anyone help me out? Will I just have to wait for SciPy to release a compatible version?
If its helpful, I am working on a M1 processor with MacOS 11.3.1, and using python 3.8.2.
I have tried using homebrew as outlined here:
https://stackoverflow.com/a/66536896/16461391.
I have tried using miniforge as outlined here:
https://stackoverflow.com/a/66768260/16461391.

I managed to find a way to do it. I'm just posting my answer here in case someone else is stuck on the problem.
The way I did it was by running in terminal:
conda install -c conda-forge keras
then I checked it was installed in my condo env using the anaconda navigator, then I opened the condo environment in pycharm by following the steps here:
https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html.

Related

Failing to set up TensorFlow on Mac

I am trying to set up a ML environment on my new Mac device which has a M1 chip. I followed this guide to get TensorFlow installed. However I do not know how to set up the environment on Pycharm. When I try to install Tensorflow as a package it outputs the following:
ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none)
ERROR: No matching distribution found for tensorflow-macos
I have tried using different Python versions but it the same output keeps popping.
Could you help me with setting up the environment on Pycharm? More specifically what environment and interpreter should I select?
Thank you.
For me, I always follow this repository (Thanks to Daniel Bourke). Follow this steps which are provided in the repository and I hope this will get the job done. Enjoy <3
https://github.com/mrdbourke/m1-machine-learning-test
Try:
brew install hdf5
export HDF5_DIR=/opt/homebrew/opt/hdf5
pip install --no-binary=h5py h5py
pip install tensorflow-macos
This worked for me.
I use Anaconda on my Macbook Pro M1 and set up a separate environment for each problem. Works fine.

TensorFlow (any version > 2.5.0) on M1 Mac: No code completion in PyCharm

I am using JetBrain's PyCharm IDE to work with TensorFlow on a M1 Mac machine.
I have installed TensorFlow using the following commands in the given order:
conda create -n data-science -y python=3.9
conda activate data-science
conda install -c apple tensorflow-deps
pip install tensorflow-macos
pip install tensorflow-metal
For installing Conda, I followed Apple's official documentation
I can import TensorFlow without problems; the version number it prints is 2.8.0.
However, I am not getting any code completion suggestions.
When typing tensorflow.keras.l, it should suggest layers, or losses.
As the attached screenshot shows, I am not getting anything usable:
I have restarted the IDE, invalidated any caches, re-indexed the project, and re-created the environment from scratch multiple times, all to no avail. Other suggestions are working as expected (such as the os.path.join line in the screenshot). What puzzles me is that, in another project on the very same machine (M1 Mac), I am using TensorFlow 2.5.0, which gives me the desired code suggestions.
The inability to get code suggestion for more recent TensorFlow versions has stopped me from updating to, e.g., version 2.8.0. What are your suggestions to solve this issue?
For code completion you can follow below workaround
from tensorflow import keras
if typing.TYPE_CHECKING:
from keras.api._v2 import keras
For more details please refer here.

Why am I having errors while installing Tensorflow?

I had issues with my Tensorflow and had to re-install it. In order to ensure I do not make mistakes like I have done before, I followed Jeff Heaton tutorials (available here) for installing Tensorflow for CPU. However, on executing the command: conda env create -v -f tensorflow.yml, I get some massive error (please see details here!).
Kindly show me where I am getting it wrong.
I have tried both 2020 and 2019 versions of anaconda. Using Miniconda did not help either.
Thank you very much.
Follow the installation instructions on Anaconda's website for TensorFlow for CPU:
conda create -n tensorflow_env tensorflow
conda activate tensorflow_env
Pls, retry with anaconda
I hope it helps and to you
Download the latest version of anaconda, and start "Anaconda promt(anaconda)", then write this in Anaconda terminal
pip install tensorflow
And for test
python3
import tensorflow
If you haven't got errors, You succefully install library.

Install scikit-learn on Mac

I am new to the developer world. I tried to install Python and scikit-learn on my Mac for a new project. I installed the other packages (NumPy, pandas, etc.) which worked. However with scikit-learn I am getting an error. I used pip install sickt-learn and the installation start. For whatever reason I got the error message below.
I am using Python version 3.8.0 (global) on a OSx machine 10.14.6. What did I wrong?
Thank you for your support!
enter image description here
Maybe you should run first:
pip install Cython

Installing SciPy for Python 3.7 on Mac Os High Sierra

please help installing SciPy. I think i've tried almost any advice i could find, but still no luck.
I am using Mac High OS Sierra 10.13.1, python 3.7, trying to make this work for IntellIJ IDEA 2017.2 IDE. I have Xcode version 9.2 if that helps.
I've tried instaling from IDE, using package installer -> fails with error status code 1.
I've tried installing using pip3 install scipy
I've installed brew install gcc ( I have version 7.2.0 installed)
I've installed numpy.
I've tried to install using Macports as suggested on official site - didn't help.
I've tried to instal using brew install scipy.
I've tried to install using Conda. It installed somewhere to Conda Dir, but i still cannot access library from python file using import scipy, error: No module named scipy.
Looks like i am just going in loops now, can some one suggest any idea please?
Topics i researched:
SciPy build/install Mac Osx
Can't install Scipy through pip
"failed with error code 1" while installing scipy
Some other ones i lost links to.
Ok looks like i made it work.
This thread: helped me.
It appeared I was actaully able to install scipy package using conda. But my Python didn't see the package. So i had to:
Change Right Click on my project in IDE > Project > New > Python SDK > Add Local
Select Python in Conda dir. In my case it was /Users/[my user ]/miniconda3/bin/python3.6
Restart IDE just in case and my python script was able to see import scipy.
The downside of this - that I cannot install packages the clean way from IDE anymore for some reason. I.e. Tools > Manage Python Packages > + > doesn't find any. And I have to reinstall all the packages i had using conda install [package name] from terminal . But I am fine with it, as long as it works.
Hopefully my quest might be useful for someone.

Categories