머신러닝,딥러닝/numpy 강의&프리코스

starting conda & jupyter notebook on mac

mcdn 2021. 12. 7. 16:45
반응형

https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html

 

Getting started with conda — conda 4.11.0.post8+f60f0f16 documentation

Tip When the environment is deactivated, its name is no longer shown in your prompt, and the asterisk (*) returns to base. To verify, you can repeat the conda info --envs command.

docs.conda.io

 

공식 문서 그대로 따라갔다 

 

 

1. conda 설치 

https://docs.anaconda.com/anaconda/install/mac-os/

 

Installing on macOS — Anaconda documentation

Installing on macOS You can install Anaconda using either the graphical installer (“wizard”) or the command line (“manual”) instructions below. If you are unsure, choose the graphical install. macOS graphical install Download the graphical macOS in

docs.anaconda.com

https://www.anaconda.com/products/individual#macos

 

Anaconda | Individual Edition

Anaconda's open-source Individual Edition is the easiest way to perform Python/R data science and machine learning on a single machine.

www.anaconda.com

두번째 페이지에서 설치 패키지를 다운 받을 수 있다. 

첫번째 페이지에서는 설치 과정을 설명함 

 

설치를 하는데 5분 정도 걸림 

 

 

2.  conda 설치 확인 

Managing conda

Verify that conda is installed and running on your system by typing:

conda --version

Conda displays the number of the version that you have installed. You do not need to navigate to the Anaconda directory.

EXAMPLE: conda 4.7.12

Note

If you get an error message, make sure you closed and re-opened the terminal window after installing, or do it now. Then verify that you are logged into the same user account that you used to install Anaconda or Miniconda.

 

설치를 완료하면 터미널을 완전 끄고 다시 킨다음 

conda --version을 쳐보자 

2021년 12월 7일 새로 설치하면 4.10.3 버전이 나온다 

 

 

터미널을 완전 끄고 다시 키는게 중요하다 

 

 

3. conda 실행 

conda는 가상환경을 만드는 패키지다 

가상환경 만드는 명령어는 conda create이다. 

conda create -n [가상환경이름] [패키지]

공식 문서는 

conda create -n snowflakes biopython 

을 썼다. snowflakes라는 이름의 환경에 biopython을 설치한다는 뜻 

 

내 경우에는 강의 대로 따라가서 upstage라는 이름을 써서 실행 

(base) ➜  ~ conda create -n upstage python=3.8
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/a/opt/anaconda3/envs/upstage

  added / updated specs:
    - python=3.8


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2021.10.8          |   py38hecd8cb5_0         151 KB
    ncurses-6.3                |       hca72f7f_2         856 KB
    pip-21.2.4                 |   py38hecd8cb5_0         1.8 MB
    python-3.8.12              |       h88f2d9e_0        10.3 MB
    setuptools-58.0.4          |   py38hecd8cb5_0         791 KB
    ------------------------------------------------------------
                                           Total:        13.9 MB

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/osx-64::ca-certificates-2021.10.26-hecd8cb5_2
  certifi            pkgs/main/osx-64::certifi-2021.10.8-py38hecd8cb5_0
  libcxx             pkgs/main/osx-64::libcxx-12.0.0-h2f01273_0
  libffi             pkgs/main/osx-64::libffi-3.3-hb1e8313_2
  ncurses            pkgs/main/osx-64::ncurses-6.3-hca72f7f_2
  openssl            pkgs/main/osx-64::openssl-1.1.1l-h9ed2024_0
  pip                pkgs/main/osx-64::pip-21.2.4-py38hecd8cb5_0
  python             pkgs/main/osx-64::python-3.8.12-h88f2d9e_0
  readline           pkgs/main/osx-64::readline-8.1-h9ed2024_0
  setuptools         pkgs/main/osx-64::setuptools-58.0.4-py38hecd8cb5_0
  sqlite             pkgs/main/osx-64::sqlite-3.36.0-hce871da_0
  tk                 pkgs/main/osx-64::tk-8.6.11-h7bc2e8c_0
  wheel              pkgs/main/noarch::wheel-0.37.0-pyhd3eb1b0_1
  xz                 pkgs/main/osx-64::xz-5.2.5-h1de35cc_0
  zlib               pkgs/main/osx-64::zlib-1.2.11-h1de35cc_3


Proceed ([y]/n)? y <- 여기서 한번 y를 쳐야 함 


Downloading and Extracting Packages
python-3.8.12        | 10.3 MB   | ##################################### | 100%
pip-21.2.4           | 1.8 MB    | ##################################### | 100%
certifi-2021.10.8    | 151 KB    | ##################################### | 100%
ncurses-6.3          | 856 KB    | ##################################### | 100%
setuptools-58.0.4    | 791 KB    | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate upstage
#
# To deactivate an active environment, use
#
#     $ conda deactivate

(base) ➜  ~

시간 조금 흐르고 설치가 환료된다 

 

# To activate this environment, use
#
#     $ conda activate upstage
#
# To deactivate an active environment, use
#
#     $ conda deactivate

위에 써져 있듯이 가상환경을 쓸려면 이 명령어를 치라고 나온다 

그럼 conda activate를 해보자 

 

 

4. conda  activate

conda activate upstage 
activate upstage (x)

밑에 꺼로 하니까 제대로 안들어가진다 

치면 아무 출력 없이 끝이 난다

 

(base) ➜  ~ activate upstage
(base) ➜  ~ conda install numpy
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

(base) ➜  ~ conda install jupyter
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

 위는 모르고 base에다가 설치한 경우 ㅜㅜ 

이건 가상환경을 제대로 쓴게 아니다 

 

(base) ➜  ~ conda activate upstage
(upstage) ➜  ~ conda install numpy
Collecting package metadata (current_repodata.json): done
Solving environment: done

옆에 (base)가 아까 설정한 이름 (upstage)로 바뀌어야 

제대로 가상환경 안으로 들어온 것이다 

 

여기서 필요한 패키지를 설치하자 

 

5. conda install 

conda install numpy 

conda install jupyter

 



Proceed ([y]/n)? ㅛㅛ y


Downloading and Extracting Packages
numpy-base-1.21.2    | 4.6 MB    | ##################################### | 100%
mkl_fft-1.3.1        | 165 KB    | ##################################### | 100%
numpy-1.21.2         | 23 KB     | ##################################### | 100%
mkl_random-1.2.2     | 273 KB    | ##################################### | 100%
mkl-service-2.4.0    | 45 KB     | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(upstage) ➜  ~

이렇게 설치 환료 

 

그럼 코드 폴더로 가서 jupyter notebook 명령어를 친다 

 

[I 16:42:52.032 NotebookApp] Jupyter Notebook 6.4.4 is running at:
[I 16:42:52.032 NotebookApp] http://localhost:8888/?token=af62593d4bd28aa47c07e00f6d8ab2a689d2c9bddc4c3aa9
[I 16:42:52.032 NotebookApp]  or http://127.0.0.1:8888/?token=af62593d4bd28aa47c07e00f6d8ab2a689d2c9bddc4c3aa9
[I 16:42:52.032 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 16:42:52.052 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///Users/a/Library/Jupyter/runtime/nbserver-9652-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=af62593d4bd28aa47c07e00f6d8ab2a689d2c9bddc4c3aa9
     or http://127.0.0.1:8888/?token=af62593d4bd28aa47c07e00f6d8ab2a689d2c9bddc4c3aa9
/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
  return _iterencode(o, 0)

그럼 해당 폴더에 있는 코드를 jupyter notebook로 실행할 수 있다 

 

이렇게 localhost:8888 에 실행됨 

신기~

 

ipynb에서 더 빛을 발할 것으로 예상됨 

 

 

반응형