问题
My tox.ini file looks like this
[tox]
envlist=py27
[testenv]
deps=
pytest
This fails to find my base python installation which is at D:\python27 and not the standard c:\python27 location
If I change tox.ini to this, it works but looks ugly.
[tox]
envlist=cpy27,dpy27
skip_missing_interpreters=True
toxworkdir={toxinidir}/build/tox
[testenv]
basepython=
cpy27: C:\Python27\python.exe
dpy27: D:\Python27\python.exe
deps=
pytest
so my question, how can I configure tox so it can figure out where python is installed on the windows machine, w/o explicitly specifying the paths as each developer may have it installed it in a different path on their machine.
回答1:
I figured this out. looks like I need to specify python2.7 instead of py27 for windows
[tox]
envlist=python2.7
This correctly detects the location of python irrespective of C or D drive.
回答2:
After a couple of days I figure out how to setup the windows 10 without changing tox.ini
, Follow the steps to get python2 and python3 setup in windows 10.
Make sure you installed python 2.7.16 which comes with its own pip. Install python 3 any version you want. Also make sure that you select custom installation and select available for all users checkbox during installation.
Now if you have python 2.7 in C:/python27
and python 3 in C:/program files/python36
then the following should be your system path
environment variables. Remember the order is important.
Following files should be in your python27
directory.
Following files should be in Scripts
of python27
Following files should be in python36
directory, duplicate python.exe
Following files should be in python36 scripts
directory
After all the above setups, you should get all in path like below
回答3:
You can use the tox plugin tox-globinterpreter to specify the paths where you have installed interpreters on your machine without having to change tox.ini
, which is especially useful if your code is shared with other people.
Just install this plugin with pip
and configure the paths using tox --scan
(use forward slashes):
pip install tox_globinterpreter
tox --scan D:/Python*/python.exe
Afterwards, tox will be able to find your Python installation.
来源:https://stackoverflow.com/questions/38271311/tox-cant-detect-python-interpreter-in-d-python27-path