DEV Community

Ravi Kumar Gupta
Ravi Kumar Gupta

Posted on

Setting up Python Development Environment on Apple M1

I recently moved to Apple M1. It was an awesome experience for my NodeJs, Java projects.

But a poor experience for python projects. I could not even install numpy properly.

I did not want to use Rosetta much. So, I had to install numpy using source. But then pandas did not install, then scipy has problems… Tired.

If you’ve reached here, you would have got a lot of articles where people tried to install by source or other ways. In this story, I am jumping straight to the solution which worked for me using miniforge

Install miniforge

brew install miniforge
Enter fullscreen mode Exit fullscreen mode

Setup conda with your shell(zsh or bash, whatever you use)

conda init zsh
Enter fullscreen mode Exit fullscreen mode

Create your venv using desired python version

conda create -n .venv python=3.9.2
Enter fullscreen mode Exit fullscreen mode

This will create a virtual env for python 3.9.2. All the packages you install will go inside this environment.

Now you can just go your python code directory and activate virtual env.

cd /path/to/my/python/source/dir
conda activate .venv
Enter fullscreen mode Exit fullscreen mode

Install the packages. Few packages I was not able to find in conda so if I install using pip that worked fine.

conda install numpy
conda install pandas
Enter fullscreen mode Exit fullscreen mode

Or using Pip

pip install celery
Enter fullscreen mode Exit fullscreen mode

That’s it, now you can simply run your app.

Hope this helps you. :)

You can follow me on Twitter — @kravigupta . You can also connect on LinkedIn — kravigupta.

Cheers!!

Top comments (0)