Environment
- MacOS Catalina 10.15.7
- Python 3.9.7
Problem
When running tox with pyenv virtual environment, an error is raised like
1
2
3
4
5
6
|
$ tox -r
...
py37 create: /Users/tatsuro.homma/repo/a/lib/thrift/AltKankoku/.tox/py37
ERROR: InterpreterNotFound: python3.7
py38 create: /Users/tatsuro.homma/repo/a/lib/thrift/AltKankoku/.tox/py38
ERROR: InterpreterNotFound: python3.8
|
tox.ini
1
2
3
4
5
6
7
8
|
[tox]
envlist=py27, py37, py38, py39
indexserver =
default = https://hoge/simple
deps =
-rrequirements.txt
[testenv]
commands = python setup.py sdist bdist_wheel
|
pyenv is installed, but py3.7 or 3.8 was not activated.
1
2
3
4
5
6
|
$ pyenv versions
* system (set by /Users/a-user/.python-version)
2.7.15
3.7.8
3.8.6
3.9.7
|
Solution
For running multiple versions of python on tox with pyenv, change ~/.python-version
like below:
~/.python-version
1
2
3
4
|
2.7.15
3.7.8
3.8.6
3.9.7
|
Then you can see multiple versions of python are activated.
1
2
3
4
5
6
|
$ pyenv versions
system
* 2.7.15 (set by /Users/tatsuro.homma/.python-version)
* 3.7.8 (set by /Users/tatsuro.homma/.python-version)
* 3.8.6 (set by /Users/tatsuro.homma/.python-version)
* 3.9.7 (set by /Users/tatsuro.homma/.python-version)
|
You can run tox
1
2
3
4
5
6
7
8
|
$ tox -r
...
...
py27: commands succeeded
py37: commands succeeded
py38: commands succeeded
py39: commands succeeded
congratulations :)
|