0
2

More than 3 years have passed since last update.

Pythonを2.7から3.7に更新する

Last updated at Posted at 2019-12-16

背景

requireとhttpbinライブラリをインストールしようとしたらアップデートを推奨されたのでアップデートしてみる

$>python --version
Python 2.7.17

$>pip --version
pip 19.2.3 from c:\python27\lib\site-packages\pip (python 2.7)

$>pip install requests
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 wo
n't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2
 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting requests
  Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb
/requests-2.22.0-py2.py3-none-any.whl (57kB)
     |################################| 61kB 596kB/s
Collecting idna<2.9,>=2.5 (from requests)
  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9
/idna-2.8-py2.py3-none-any.whl (58kB)
     |################################| 61kB 2.3MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8
/chardet-3.0.4-py2.py3-none-any.whl (133kB)
     |################################| 143kB 1.3MB/s
Collecting certifi>=2017.4.17 (from requests)
  Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99
/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
     |################################| 163kB 1.3MB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests)
  Downloading https://files.pythonhosted.org/packages/b4/40/a9837291310ee1ccc242ceb6ebfd9eb21539649f193a7c8c86ba15b98539
/urllib3-1.25.7-py2.py3-none-any.whl (125kB)
     |################################| 133kB 1.0MB/s
Installing collected packages: idna, chardet, certifi, urllib3, requests
Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.7
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

手順

Windows環境なので、やる事は公式ホームページからインストーラをダウンロードして実行するだけ。
しかしインストール後にバージョン確認すると、更新前のバージョンを指示している。
どうやら新旧のバージョンが衝突しているらしい。

$>where python
C:\Python27\python.exe
C:\Users\....\AppData\Local\Programs\Python\Python37-32\python.exe

$>python --version
Python 2.7.17

環境変数PATHから旧版のパスである"C:\Python27\;C:\Python27\Scripts;"を削除する。
改めてバージョン確認を行い、期待する動作を確認。

$>python --version
Python 3.7.2

$>where python
C:\Users\....\AppData\Local\Programs\Python\Python37-32\python.exe

$>python -m pip --version
pip 19.3.1 from C:\Users\....\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pip (python 3.7)

改めてrequireパッケージをインストール

$>python -m pip install require
Collecting require
  Downloading https://files.pythonhosted.org/packages/ef/77/292381a3dd42abffee3e8270531578d7ab862ee1191787f7528cea272ca0
/require-0.1.1.tar.gz
Installing collected packages: require
    Running setup.py install for require ... done
Successfully installed require-0.1.1

$>python -m pip install requests
Collecting requests
  Using cached https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7f
b/requests-2.22.0-py2.py3-none-any.whl
Collecting certifi>=2017.4.17
  Using cached https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e9
9/certifi-2019.11.28-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b
8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5
  Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c
9/idna-2.8-py2.py3-none-any.whl
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Using cached https://files.pythonhosted.org/packages/b4/40/a9837291310ee1ccc242ceb6ebfd9eb21539649f193a7c8c86ba15b9853
9/urllib3-1.25.7-py2.py3-none-any.whl
Installing collected packages: certifi, chardet, idna, urllib3, requests
  WARNING: The script chardetect.exe is installed in 'C:\Users\....\AppData\Local\Programs\Python\Python37-3
2\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.7

WARNIGメッセージに従い、以下のパスを環境変数PATHに追加

C:\Users\....\AppData\Local\Programs\Python\Python37-32\Scripts

chardetectにアクセスして、設定が正しい事を確認

$>where chardetect
C:\Users\....\AppData\Local\Programs\Python\Python37-32\Scripts\chardetect.exe

$>chardetect --version
chardetect 3.0.4

httpbinパッケージをインストール

$>pip install httpbin
Collecting httpbin
  Downloading https://files.pythonhosted.org/packages/【中略】/httpbin-0.7.0-py2.py3-none-any.whl (86kB)
     |████████████████████████████████| 92kB 980kB/s
Collecting werkzeug>=0.14.1
  Downloading https://files.pythonhosted.org/packages/【中略】/Werkzeug-0.16.0-py2.py3-none-any.whl (327kB)
     |████████████████████████████████| 327kB 6.8MB/s
Collecting six
  Downloading https://files.pythonhosted.org/packages/【中略】/six-1.13.0-py2.py3-none-any.whl
Collecting Flask
  Downloading https://files.pythonhosted.org/packages/【中略】/Flask-1.1.1-py2.py3-none-any.whl (94kB)
     |████████████████████████████████| 102kB 1.7MB/s
Collecting raven[flask]
  Downloading https://files.pythonhosted.org/packages/【中略】/raven-6.10.0-py2.py3-none-any.whl (284kB)
     |████████████████████████████████| 286kB 6.8MB/s
Collecting MarkupSafe
  Downloading https://files.pythonhosted.org/packages/【中略】/MarkupSafe-1.1.1-cp37-cp37m-win32.whl
Collecting decorator
  Downloading https://files.pythonhosted.org/packages/【中略】/decorator-4.4.1-py2.py3-none-any.whl
Collecting brotlipy
  Downloading https://files.pythonhosted.org/packages/【中略】/brotlipy-0.7.0.tar.gz (413kB)
     |████████████████████████████████| 419kB 6.8MB/s
Collecting itsdangerous
  Downloading https://files.pythonhosted.org/packages/【中略】/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting click>=5.1
  Downloading https://files.pythonhosted.org/packages/【中略】/Click-7.0-py2.py3-none-any.whl (81kB)
     |████████████████████████████████| 81kB 1.1MB/s
Collecting Jinja2>=2.10.1
  Downloading https://files.pythonhosted.org/packages/【中略】/Jinja2-2.10.3-py2.py3-none-any.whl (125kB)
     |████████████████████████████████| 133kB 6.8MB/s
Collecting blinker>=1.1; extra == "flask"
  Downloading https://files.pythonhosted.org/packages/【中略】/blinker-1.4.tar.gz (111kB)
     |████████████████████████████████| 112kB 2.2MB/s
Collecting cffi>=1.0.0
  Downloading https://files.pythonhosted.org/packages/【中略】/cffi-1.13.2-cp37-cp37m-win32.whl (163kB)
     |████████████████████████████████| 163kB ...
Collecting pycparser
  Downloading https://files.pythonhosted.org/packages/【中略】/pycparser-2.19.tar.gz (158kB)
     |████████████████████████████████| 163kB 3.2MB/s
Installing collected packages: werkzeug, six, itsdangerous, click, MarkupSafe, Jinja2, Flask, blinker, raven, decorator,
 pycparser, cffi, brotlipy, httpbin
    Running setup.py install for blinker ... done
    Running setup.py install for pycparser ... done
    Running setup.py install for brotlipy ... done
Successfully installed Flask-1.1.1 Jinja2-2.10.3 MarkupSafe-1.1.1 blinker-1.4 brotlipy-0.7.0 cffi-1.13.2 click-7.0 decor
ator-4.4.1 httpbin-0.7.0 itsdangerous-1.1.0 pycparser-2.19 raven-6.10.0 six-1.13.0 werkzeug-0.16.0

終わりに

特に問題無くインストールが完了しました。
パッケージがあるのは素晴らしいデスネ。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2