LoginSignup
1
6

More than 5 years have passed since last update.

python3 venvで環境作成

Last updated at Posted at 2018-01-12

pyenvとかvirtualenvとか色々あるらしいけど、これが公式でおすすめらしい。

~$ sudo apt install python3-venv

~$ python3 -m venv ./myvenv/
~$ ls
memo.txt  myvenv


~$ . myvenv/bin/activate
(myvenv) ~$
(myvenv) ~$ python --version
Python 3.5.2

簡単ですね。

【追記】

Pythonのバージョンを変えたい。

~$ cat myvenv/pyvenv.cfg
home = /usr/bin
include-system-site-packages = false
version = 3.5.2

Ubuntuに入ってたPython3は3.5.2だったみたい。
3.6.3にしたいとおもいました。

Python3.6.3のインストール方法
https://www.python.jp/install/ubuntu/index.html

インストールしたら、下記で新しい環境を作る。

python3.6 -m venv --without-pip ./myvenv2

~$ . myvenv2/bin/activate
(myvenv2)~$ python --version
Python 3.6.3

できたっぽいです。

1
6
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
1
6