Python + Ubuntu

since 2019-07-18

Windows 10 WSL + Ubuntu 16.04 で Python 3.7.4 を使う。

make altinstall が推奨されている

$ pwd

$ wget

$ tar zxvf Python-3.7.4.tgz 
$ cd Python-3.7.4
$ sudo ./configure --enable-optimizations
$ sudo make altinstall

$ which python3.7

$ python3.7 -V
Python 3.7.4

ちなみに、以下は標準で入っている、または apt で入る Python

$ python -V
Python 2.7.12

$ python3 -V
Python 3.5.2

$ python3.6 -V
Python 3.6.5

$ python2 -V
Python 2.7.12

pip とか venv とか

$ python3.7 -m pip -V
pip 19.0.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

$ python3.7 -m venv -h
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear]
            [--upgrade] [--without-pip] [--prompt PROMPT]
            ENV_DIR [ENV_DIR ...]

Creates virtual Python environments in one or more target directories.

positional arguments:
  ENV_DIR               A directory to create the environment in.

optional arguments:
  -h, --help            show this help message and exit
                        Give the virtual environment access to the system
                        site-packages dir.
  --symlinks            Try to use symlinks rather than copies, when symlinks
                        are not the default for the platform.
  --copies              Try to use copies rather than symlinks, even when
                        symlinks are the default for the platform.
  --clear               Delete the contents of the environment directory if it
                        already exists, before environment creation.
  --upgrade             Upgrade the environment directory to use this version
                        of Python, assuming Python has been upgraded in-place.
  --without-pip         Skips installing or upgrading pip in the virtual
                        environment (pip is bootstrapped by default)
  --prompt PROMPT       Provides an alternative prompt prefix for this

Once an environment has been created, you may wish to activate it, e.g. by
sourcing an activate script in its bin directory.

pip はシステムのものを更新しておく

$ sudo /usr/local/bin/python3.7 -m pip install -U pip

だが venv を activate すると、なぜかまた古い pip に戻っているので、もういちど pip install -U pip する。

python_ubuntu.txt · 最終更新: 2019/07/19 16:33 by Takuya Nishimoto Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0