MiniBitePython - #0 Setup Python environment with miniconda | 使用 miniconda 設置 Python 環境

in hive-105017 •  10 days ago 

我在工作時有同事問起有關初學 Python 時的問題,希望可以有一些實用點的方式來學習,可惜網上缺少這種資訊。(說穿了是不太會使用Google)。所以我想創一個 Series,搞點簡單的 use case 來讓他學習。以下是系列記錄。


So I get comments from friends who read my recent MiniBitePython posts. He suggests I should write something regarding how to install a working python environment first. He had quite a frustrating moments when catching up at the very beginning. Without further ado, here we go.



0. What is miniconda and why should I install it?

Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. Use the conda install command to install 720+ additional conda packages from the Anaconda repository (take it as a supermarket store that you can grab package from).
Source - Miniconda

簡單來說,miniconda 就是一個預先配好的最精簡所需運行 Python 環境的懶人包。安裝好後,可以使用conda install的指令來快速安裝在Anaconda上有的其他packages/libraries.

1. Install miniconda | 安裝 miniconda
You can go ahead to the above link and download the package that will run on your computer OS. For MacOSX users, be careful and choose the Miniconda3 MacOSX 64-bit pkg. When the package is successfully downloaded, just open the installers and follow through the instructions.

你可以到上面的鏈接並下載與你的電腦操作系統相容的軟件安裝包運行。而對於MacOSX用戶,請小心並選擇Miniconda3 MacOSX 64位pkg。 在成功下載軟件包後,隻需打開安裝程序並按照說明進行操作即可。

These Miniconda installers contain the conda package manager and Python. Once Miniconda is installed, you can use the conda command to install any other packages and create environments, etc. For example:

Miniconda安裝包包含了名為conda的軟件包管理器和Python。 一旦安裝了Miniconda,就可以使用conda指令安裝任何其他軟件包和創建環境等。例如:

To install a numpy package from the Anaconda repository | 安裝 numpy:
$ conda install numpy

To create an environment named mytest that has python 3.8 | 創建一個具有python 3.8名為mytest的環境:
$ conda create -n mytest python=3.8

To activate the newly created environment named mytest | 運行名為mytest的環境:
$ conda activate mytest

There you go, you can now use python freely by creating and installing different environment with different packages.

至此,你已經可以開心使用 python 了。

Previously on miniBitePython,

MiniBitePython - #1 Create python .py script | 創建Python腳本
MiniBitePython - #2 Output result to .txt file with cmd | 使用cmd將結果輸出到.txt文件

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!