Windows10環境でAnaconda、Pycharmインストール・設定トライ(1)

「ゼロから作るDeep Learning」の学習を始めて3か月が経った。

過去に遡って理解に苦労した点などを記事を書くつもりであるが、

愛用のWindows VistaのPCがダウン、仕方なくWindows10のPCを購入。

早速、Anaconda、Pycharmをインストールすることにした。

 

その前に、

Python学習には、最初はIDLE → 慣れてきたらPycharm使用が良いとの記事あり。

---

 

https://gammasoft.jp/python/python-development-environment/
GAMMASOFT
ホーム> Pythonで仕事を自動化するには> プログラミング
Pythonの開発環境について(IDLEとPyCharm)
当社が普及を推進している「Pythonで仕事自動化」において、推奨している Python の開発環境は以下の2つです。
 ・IDLE(Pythonに付属)
 ・PyCharm(Community Edition:無償版)
まずはIDLEでプログラミングをすぐに始める
慣れたらPyCharmに乗り換える

---

おお良いね。だいぶ慣れてきたところ。

-----------------------------------------------

1. Anacondaインストール

参考サイト

https://pythondatascience.plavox.info/python%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB/python%E3%81%AE%E3%82%A4%E3%

Anaconda を利用した Python のインストール  (Windows)

 

1.1 Anaconda のダウンロード
Anaconda のダウンロードページから、Python 3.5 の 64 bit のインストーラをダウンロード。2018/4
https://www.anaconda.com/download/#_windows
Anaconda 5.1 For Windows Installer
Python 3.6 version *
64-Bit Graphical Installer (537 MB)

 

1.2 Anaconda のインストール
・ダウンロードしたファイルを開き、インストーラを起動。
「Next」を押して次に進む。
・ライセンスを確認し、「I Agree」を押して次に進む。
・「Just Me」を選択されていることを確認し、「Next」を押して次に進む。
・インストール先を尋ねられるので、「Next」を押して次に進む。
・2 つのチェックボックス (環境変数 PATH への設定、Python 3.5 をデフォルトの Python として登録) にチェックが入っていることを確認し、「Next」を押して次に進む。
 注) Add Anconda to my PATH environment variable(環境変数 PATH への設定)は、Not recommended ...と赤字表示されるが、チェックを入れたほうが便利。
 コマンドプロンプトを起動したとき、何処のディレクトリでもpythonを実行できる。
 なお、インストール時Anaconda Promptなるものが作成されるので、ここで作業する限り、ディレクトリを移動しなくても良いだが。

・インストールが始まる。
・Install microsoft VSCcode→Skip
・Finish」を押し、インストーラを閉じる。

 

1.3 Windows標準コマンドプロンプト起動
Add Anconda to my PATH environment variable(環境変数 PATH への設定)にチェックを入れてインストールした場合、何処のディレクトリでもpythonを実行できる。

 

プロンプト起動

Microsoft Windows [Version 10.0.16299.371]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\...-pc>

Python起動

C:\Users\...-pc>python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Python起動した、OK!、exit()する。
>>> exit()

C:\Users\...-pc>

 

1.4 Anaconda Prompt 起動

Anaconda Prompt を起動する
「スタートボタン」 ⇒ 「すべてのアプリ」 ⇒ 「Anaconda Prompt」 を選択する。

(base) C:\Users\...-pc>

 

1.5 pip のアップグレード

(base) C:\Users\...-pc>python -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl (1.3MB)
100% |????????????????????????????????| 1.3MB 1.6MB/s
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-10.0.0
(base) C:\Users\...-pc>

再度やってみる。
(base) C:\Users\...-pc>python -m pip install --upgrade pip
Requirement already up-to-date: pip in c:\users\suga-pc\anaconda3\lib\site-packages (10.0.0)

OK!もう良し。


1.6 pip コマンドのオプション
pip --help コマンドを実行すると、アンインストールなど、pip コマンドを利用して可能な操作が一覧表示される。

(base) C:\Users\...-pc>pip --help

Usage:
pip <command> [options]

Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.

General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to
WARNING, ERROR, and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
(a)bort).
--trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the
certificate in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for
download. Implied with --no-index.
--no-color Suppress colored output

(base) C:\Users\     >

Anacondaインストール無事終了。

 

一応、環境変数・pathチェックしてみる。 

コントロールパネル→システムとセキュリティ→システム→システムの詳細設定を順にたどって、環境変数設定表示。

(コンピューター名)ユーザ環境変数 → pathへ

下記path設定あり。

C:\Users\(コンピューター名)\Anaconda3・・・ここにpython.exe

C:\Users\(コンピューター名)\Anaconda3\Library\mingw-w64\bin

C:\Users\(コンピューター名)\Anaconda3\Library\usr\bin

C:\Users\(コンピューター名)\Anaconda3\Library\bin

C:\Users\(コンピューター名)\Anaconda3\Scripts

python.exeがあるpathも設定されており、コマンドプロンプトが何処のディレクトリでも実行可能であることが分かる。

 

なお、Python統合開発環境IDLEは、

C:\Users\(コンピューター名)\Anaconda3\Scripts\idle.exe

にあり、ショートカットを作っておくと便利。

 

idle.exe起動で、

Python 3.6.4 Shell起動画面

 

File>New Fileで

UntiltedのPythonコード開発画面

  

 

次、PyCharmにトライ。