3

My pyenv is using Python 3.7, and yet when running tox on a project that has envlist = py37, it is using Python 2.7 to run the setup.py and failing:

Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from setuptools import setup, find_namespace_packages
ImportError: cannot import name find_namespace_packages

============================================================================================================== log end ==============================================================================================================
ERROR: FAIL could not package project - v = InvocationError(u'/usr/local/opt/python@2/bin/python2.7 setup.py sdist --formats=zip --dist-dir /Users/j/workspace/core/python/utils/.tox/dist', 1)

What needs to be configured to get tox to use Python 3? Is there any other information needed to answer this question?

jacob
  • 2,762
  • 1
  • 20
  • 49
  • 1
    It seems that tox was installed in both the system and pyenv shim environment, and it was using the system tox even though the pyenv shim was active. I uninstalled the system tox, and now it works. I'm not sure why it was doing that. – jacob Aug 20 '20 at 19:55
  • 2
    You should add your above comment as an answer and accept it. – jarcobi889 Aug 20 '20 at 21:37
  • 1
    Indeed. I also just solved my problem of tox using the sytem's python version instead of the one specified in tox.ini (which was installed via pyenv) by uninstalling tox with apt and re-installing it with pip. – Pere Picornell Apr 23 '21 at 14:29

1 Answers1

0

I just bumped into a similar problem, but I wanted to use a global version of tox rather than having to install one into my pyenv virtualenv. Maybe my answer to that problem will help someone.

Dawngerpony
  • 3,288
  • 2
  • 34
  • 32