Set up multiple python installations on windows with tox

2024/9/8 10:59:46

I am trying to set up tox on windows to run tests against multiple python installations. I have installed each python in folders named, C:\Python\PythonXX_YY, XX is the python version (e.g. 27) and YY is either 32 or 64. Currently, the only python in my PATH is C:\Python\Python33_64, since I use the new python launcher to run whichever version I want. I am also running tox from this version.

The first problem is that tox doesn't detect these installations, presumably because they are not in the default locations. I can get around this by setting the path in tox.ini for each environment, but it makes the setup very specific to my computer. Is there a better way of letting tox know where my pythons are globally?

The second problem is that, setting the python locations in tox.ini, I get the following error when I run it (for Python27):

Traceback (most recent call last):File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 2557, in <module>main()File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 961, in mainnever_download=options.never_download)File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 1062, in create_environmentsite_packages=site_packages, clear=clear))File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 1255, in install_pythoncopy_required_modules(home_dir)File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 1193, in copy_required_modulesdst_filename = change_prefix(filename, dst_prefix)File "c:\Python\Python33_64\lib\site-packages\virtualenv.py", line 1164, in change_prefix(filename, prefixes)
AssertionError: Filename c:\Python\Python33_64\lib\site-packages\readline.py does not start with any of these prefixes: ['c:\\python\\python27_64']ERROR: InvocationError: c:\python\python27_64\python.exe c:\Python\Python33_64\lib\site-packages\virtualenv.py --distribute py27 (see C:\Users\david.townshend\Documents\Global\Programming\norman\.tox\py27\log\py27-0.log)

It looks like its trying to install Python2.7 stuff from Python3.3, but I've never really used virtualenv much before so I might be mis-intepreting this error.

I'm not sure what the solution is to this, but it seems to me that the obvious solution should be for tox to use the python launcher to get the python version it needs. Is there a way to make it do this?

Answer

I'm not sure if Tox did this when the OP first asked the question but it seems one may now setup each environment individually as follows :

[tox]
envlist = pyw35,pyw36
skip_missing_interpreters=True[testenv]
commands = {envpython} setup.py test[testenv:pyw35]
basepython = C:/Python/64bit/351/python.exe[testenv:pyw36]
basepython = C:/Python/64bit/362/python.exe

user330612 provides a variation upon this, but I personally could not get it to work.

[testenv]
commands = {envpython} setup.py test
basepython=pyw35: C:/Python/64bit/351/python.exepyw36: C:/Python/64bit/362/python.exe
https://en.xdnf.cn/q/72813.html

Related Q&A

How can I change the alpha value dynamically in matplotlib python

Im seeking how to change an alpha value dynamically which are already plotted.This is a kind of sample code I want to implement, but I know it is a wrong writing.import matplotlib.pyplot as pltfig = pl…

How to detect write failure in asyncio?

As a simple example, consider the network equivalent of /dev/zero, below. (Or more realistically, just a web server sending a large file.)If a client disconnects early, you get a barrage of log message…

how to get place details from place id in google places api for python

I am using the Google Places API with Python to build a collective intelligence app for food. e.g. what restaurants are around, what ratings they have, what are their timings, etc.I am doing the follow…

pandas.algos._return_false causes PicklingError with dill.dump_session on CentOS

I have a code framework which involves dumping sessions with dill. This used to work just fine, until I started to use pandas. The following code raises a PicklingError on CentOS release 6.5:import pan…

How to send an image directly from flask server to html?

I am new to flask and am trying to make an app such an image is taken by the html and js from the webcam and then it is sent to the server with ajax request. I got this part. Then some processing is do…

Alternatives to nested numpy.where for multiconditional pandas operations?

I have a Pandas DataFrame with conditional column A and numeric column B. A B 1 foo 1.2 2 bar 1.3 3 foo 2.2I also have a Python dictionary that defines ranges of B which denote "success" g…

OpenCV findContours() just returning one external contour

Im trying to isolate letters in a captcha, I managed to filter a captcha and that result in this black and white image:But when I tried to separate the letters with findContours method of OpenCV it jus…

Selenium/ChromeDriver Unknown policy Errors

I am currently using Python (v3.5.1), Selenium (v3.7), and Chromedriver (v2.33).When I run the following command:from selenium import webdriver driver = webdriver.Chrome(C:\Program Files\ChromeWebdrive…

Mako escaping issue within Pyramid

I need to put javascript function to mako template. The first argument of this function is string, so I write in my *.mako file (dict(field_name=geom)):init_map(${field_name} );But when I see my html p…

All arguments should have the same length plotly

I try to do a bar graph using plotly.express but I find this problemAll arguments should have the same length. The length of argument y is 51, whereas the length of previously-processed arguments [x] …