Build a Python environment on your Mac with Anaconda and PyCharm

Introduction

Nice to meet you, I'm Masanari (@log_masa). I'm a sophomore in college who is mainly studying the web system. I decided to write python in a university class, so I tried to build a python environment. I hope it will be helpful for people in similar circumstances.

environment

MacOS Catalina 10.15.1

Why Anaconda

Of course, Python 2.X is already installed in the Mac environment from the beginning. But Python 2.X So let's use Python 3.X. https://www.python.org/downloads/ It's good to install Python 3 from here, but it's a hassle to collect the libraries later, so use Anaconda, which installs the libraries all at once. We will build the environment of Python 3. Let's do it

We will build the environment

Installation of Anaconda

First, install Anaconda from here https://www.anaconda.com/

Launch the downloaded package and install it according to the instructions. I think it will take 10 to 20 minutes (long ...)

スクリーンショット 2019-11-28 13.02.27.png

You have now installed python 3.

Confirmation of python 3

Let's start Terminal.

(base) macmac:~ hogehoge$

macmac is the name of your Mac. hogehoge is the name of the logged-in user. What is (base)? This is the name of the virtual environment created by Anaconda. Hmmm, if you're a fan, read this article.

python

Type in python and run it

Python 3.7.4 (default, Aug 13 2019, 15:17:50) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin

Yes. I was able to confirm python 3 of Anaconda, Inc. Since the interactive shell is running, exit.

>>> exit()

I missed it. Next, check the location of python.

which python

Now you can see the location of python.

/Users/hogehoge/opt/anaconda3/bin/python

Like this. Anaconda has now installed python 3.

Install PyCharm

PyCharm is an IDE (Integrated Development Environment) provided by JetBrains. There are Professional (paid) and Community (free). Professional is available in a $ 199 / year subscription format. It seems that you can use it for free for the first 30 days, but it seems that it is quite troublesome to move from Professional to Community. People need to be careful when using Professional only during the free period.

This time, we will use the free community.

First, install PyCharm from here https://www.jetbrains.com/pycharm/download

When you download and start it,

スクリーンショット 2019-11-28 13.59.32.png

There is an instruction like this. Let's obey.

Now you can use PyCharm. However, there is still a problem with this. When I run python from PyCharm, it runs the python that comes with the Mac environment from the beginning. So, I will set it so that python installed by Anaconda can be executed.

スクリーンショット 2019-11-28 16.03.48.png In this way, let's specify the python path confirmed earlier to the Existing interpreter. Specify a working folder for Location and press Create ... Yes, now you have an environment where you can write python.

Do Hello World!

スクリーンショット 2019-11-28 16.14.52.png

Create a python file in the specified folder and

hello.py


print('Hello World!')

PyCharm will save it for you. It's the best. Execution is performed from Add Configuration on the upper right.

スクリーンショット 2019-11-28 16.22.14.png

Give it a name and OK For Script Path, specify the file you want to execute. (Here, hello.py) Execute with Ctrl-R! !! !! !!

スクリーンショット 2019-11-28 16.30.29.png

You've successfully completed Hello World!

スクリーンショット 2019-11-28 16.31.20.png

You can also move the execution screen like this and start Terminal. Cool! !! !! !!

This completes the python environment construction using Anaconda and PyCharm. Thank you for your hard work.

in conclusion

Thank you for reading this far. I wrote an article for the first time, but it's something that can be written quickly with momentum. If you find something difficult or wrong, please let us know in the comments. We are also waiting for your impressions and requests.

I will continue to write articles that are easy for beginners to understand, as well as my own output. Thank you for following Qiita and Twitter.

Recommended Posts

Build a Python environment on your Mac with Anaconda and PyCharm
Build Python environment with Anaconda on Mac
Build a Python development environment on your Mac
Build a Python environment on your Mac using pyenv
Create a python environment on your Mac
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Build a python environment with ansible on centos6
Build a Python environment on Mac (Mountain Lion)
Try to build python and anaconda environment on Mac (by pyenv, conda)
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
Install Python3 on Mac and build environment [Definitive Edition]
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a machine learning Python environment on Mac OS
Build a Python development environment on Mac OS X
Build a python virtual environment with virtualenv and virtualenvwrapper
Create a Python environment on Mac (2017/4)
Build a python3 environment on CentOS7
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Trial and error]
Build a python data analysis environment on Mac (El Capitan)
Build a python environment on CentOS 7.7 for your home server
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
[Python] Building an environment with Anaconda [Mac]
[Python] Create a virtual environment with Anaconda
A memo with Python2.7 and Python3 on CentOS
Build a python virtual environment with pyenv
Build a Python + OpenCV environment on Cloud9
Build a modern Python environment with Neovim
Build a LAMP environment on your local Docker
Build a WardPress environment on AWS with pulumi
Build python environment with pyenv on EC2 (ubuntu)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Building a python environment with virtualenv and direnv
Simply build a Python 3 execution environment on Windows
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
[Python] Build a Django development environment with Docker
Create a python3 build environment with Sublime Text3
[Memo] Build a virtual environment with Pyenv + anaconda
Build a virtual environment with pyenv and venv
Build a Python environment with OSX El capitan
Quickly build a Python Django environment with IntelliJ
Build PyPy and Python execution environment with Docker
Build a Python machine learning environment with a container
Build a Python development environment on Raspberry Pi
Build a python execution environment with VS Code
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Easy construction]
I tried to build a Mac Python development environment with pythonz + direnv
Python + Anaconda + Pycharm environment construction
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build a Django development environment using pyenv-virtualenv on Mac
Install Python environment with Anaconda
Build a local development environment for Laravel6.X on Mac
Install selenium on Mac and try it with python
Build a python environment for each directory with pyenv-virtualenv
Create a comfortable Python 3 (Anaconda) development environment on windows
Build python3 environment with ubuntu 16.04
I made a Python3 environment on Ubuntu with direnv.
Build a GVim-based Python development environment on Windows 10 (1) Installation
Build Python environment on Windows
How to build a Django (python) environment on docker
Build python environment with direnv
Build a machine learning application development environment with Python