pyenv has to be installed from Github https://laict.medium.com/install-python-on-macos-11-m1-apple-silicon-using-pyenv-12e0729427a9
- Introduction
- Solution
- Pipenv and Conda
- How do I prevent Conda from activating the base environment by default?
- References:
The new Mac M1 contains CPU, GPU, and deep learning hardware support, all on a single chip. To leverage the new M1 chip from Python, you must use a special Python distribution called Miniforge that will maximize your performance.
If you don't install it on Miniforge you will get the following error:
# Install Miniforge
CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(brew --prefix zlib)/include -I$(brew --prefix sqlite)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix bzip2)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix sqlite)/lib" pyenv install miniforge3-4.10.3-10
# it returns something like:
# Installed Miniforge3-4.10.3-10-MacOSX-arm64 to /Users/umberto.griffo/.pyenv/versions/miniforge3-4.10.3-10
pyenv global miniforge3-4.10.3-10
conda run which python
# it returns something like:
# /Users/umberto.griffo/.pyenv/versions/miniforge3-4.10.3-10/bin/python
conda update --force conda -y
# Create a virtual environment
conda create --name mlp python=3.8
# Initialize the shell to use `conda activate` (bash, zsh or whatever)
conda init zsh
# Activate it by running
conda activate mlp
# Install TensorFlow
conda install -c apple tensorflow-deps==2.9.0 -y
python -m pip install tensorflow-macos==2.9.1
python -m pip install tensorflow-metal==0.5.0
# Check TensorFlow Version
python -c 'import tensorflow as tf; print(tf.version.VERSION)'
To create a Pipenv environment where to install the dependencies starting from a Conda's Environment, from the Pycharm terminal run:
# Activate the environment
conda activate mlp
# Setup Pipenv to use Conda's Python executable and site packages directory
pipenv --python=$(conda run which python) --site-packages
# Install the dependencies
pipenv install --dev
Disable:
conda config --set auto_activate_base false
Enable:
conda config --set auto_activate_base true
- https://github.com/jeffheaton/t81_558_deep_learning/blob/master/install/tensorflow-install-mac-metal-jul-2021.ipynb
- https://caffeinedev.medium.com/how-to-install-tensorflow-on-m1-mac-8e9b91d93706
- https://pipenv-searchable.readthedocs.io/advanced.html#pipenv-and-conda
- https://stackoverflow.com/questions/50546339/pipenv-with-conda