virtualenv: ImportError: cannot import name 'ensure_text'
Apologies I don’t have a completely reproducible environment yet, but since virtualenv==20.0.0 was released 3 hours ago I wanted to get this reported as soon as I could as it likely could affect others.
I’m not 100% certain this is virtualenv’s fault, but I have previous builds that worked and the only major difference between them (and last week) was virtualenv being updated to a new major version.
If submitting a BUG please provide:
Operating System:
- ubuntu1804 Docker Image on
gitlab-runner 12.3.0 - Python 3.6
- Running with a
toxenvironment
$ apt-get update && apt-get install -y python3-pip python3-dev apt-rdepends libpq-dev libffi-dev && /usr/bin/python3 -m pip install tox && /usr/bin/python3 -m tox -e job
...
...
932 Collecting tox
933 Downloading https://files.pythonhosted.org/packages/77/a7/a5b721d9bf955edfe36013e5ecc9136fc6b2fef622ab1797ff0560273d8e/tox-3.14.3-py2.py3-none-any.whl (80kB)
934 Collecting virtualenv>=16.0.0 (from tox)
935 Downloading https://files.pythonhosted.org/packages/62/89/72ab7d18e001a23b25eb75ce71bbf9e2a3c142e2dad2e4e2b88012e4ca25/virtualenv-20.0.0-py2.py3-none-any.whl (4.6MB)
936 Collecting importlib-metadata<2,>=0.12; python_version < "3.8" (from tox)
937 Downloading https://files.pythonhosted.org/packages/8b/03/a00d504808808912751e64ccf414be53c29cad620e3de2421135fcae3025/importlib_metadata-1.5.0-py2.py3-none-any.whl
938 Requirement already satisfied: six<2,>=1.0.0 in /usr/lib/python3/dist-packages (from tox)
939 Collecting filelock<4,>=3.0.0 (from tox)
940 Downloading https://files.pythonhosted.org/packages/93/83/71a2ee6158bb9f39a90c0dea1637f81d5eef866e188e1971a1b1ab01a35a/filelock-3.0.12-py3-none-any.whl
941 Collecting toml>=0.9.4 (from tox)
942 Downloading https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl
943 Collecting packaging>=14 (from tox)
944 Downloading https://files.pythonhosted.org/packages/98/42/87c585dd3b113c775e65fd6b8d9d0a43abe1819c471d7af702d4e01e9b20/packaging-20.1-py2.py3-none-any.whl
945 Collecting py<2,>=1.4.17 (from tox)
946 Downloading https://files.pythonhosted.org/packages/99/8d/21e1767c009211a62a8e3067280bfce76e89c9f876180308515942304d2d/py-1.8.1-py2.py3-none-any.whl (83kB)
947 Collecting pluggy<1,>=0.12.0 (from tox)
948 Downloading https://files.pythonhosted.org/packages/a0/28/85c7aa31b80d150b772fbe4a229487bc6644da9ccb7e427dd8cc60cb8a62/pluggy-0.13.1-py2.py3-none-any.whl
949 Collecting importlib-resources<2,>=1.0; python_version < "3.7" (from virtualenv>=16.0.0->tox)
950 Downloading https://files.pythonhosted.org/packages/2f/f7/b4aa02cdd3ee7ebba375969d77c00826aa15c5db84247d23c89522dccbfa/importlib_resources-1.0.2-py2.py3-none-any.whl
951 Collecting appdirs<2,>=1.4.3 (from virtualenv>=16.0.0->tox)
952 Downloading https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl
953 Collecting zipp>=0.5 (from importlib-metadata<2,>=0.12; python_version < "3.8"->tox)
954 Downloading https://files.pythonhosted.org/packages/46/42/f2dd964b2a6b1921b08d661138148c1bcd3f038462a44019416f2342b618/zipp-2.2.0-py36-none-any.whl
955 Collecting pyparsing>=2.0.2 (from packaging>=14->tox)
956 Downloading https://files.pythonhosted.org/packages/5d/bc/1e58593167fade7b544bfe9502a26dc860940a79ab306e651e7f13be68c2/pyparsing-2.4.6-py2.py3-none-any.whl (67kB)
957 Installing collected packages: zipp, importlib-metadata, importlib-resources, appdirs, filelock, virtualenv, toml, pyparsing, packaging, py, pluggy, tox
958 Successfully installed appdirs-1.4.3 filelock-3.0.12 importlib-metadata-1.5.0 importlib-resources-1.0.2 packaging-20.1 pluggy-0.13.1 py-1.8.1 pyparsing-2.4.6 toml-0.10.0 tox-3.14.3 virtualenv-20.0.0 zipp-2.2.0
959 job create: /builds/.tox/job
960 ERROR: invocation failed (exit code 1), logfile: /builds/.tox/job/log/job-0.log
961 ================================== log start ===================================
962 ERROR:root:ImportError: cannot import name 'ensure_text'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 10
- Comments: 32 (19 by maintainers)
Commits related to this issue
- workaround https://github.com/pypa/virtualenv/issues/1551#issuecomment-584148133 Change-Id: I69aa935ff10fe1f6c2d2e83fdc14fad67c920a4c — committed to sapcc/manila by Carthaca 4 years ago
- workaround https://github.com/pypa/virtualenv/issues/1551#issuecomment-584148133 Change-Id: I69aa935ff10fe1f6c2d2e83fdc14fad67c920a4c — committed to sapcc/manila by Carthaca 4 years ago
- workaround https://github.com/pypa/virtualenv/issues/1551#issuecomment-584148133 — committed to sapcc/keystone by Carthaca 4 years ago
- Fix unpinned tests (#7760) Our nightly tests failed last night due to a new release of `virtualenv` and `pip`'s lack of dependency resolution: https://travis-ci.com/certbot/certbot/jobs/285797857#L28... — committed to certbot/certbot by bmw 4 years ago
- [install-deps]Install "virtualenv<20.0.1" New release of virtualenv broke the venv creation and started returning 'ensure_text' module not found. Here is the related issue: https://github.com/pypa/vi... — committed to openstack-archive/tripleo-quickstart by chkumar246 4 years ago
- Update git submodules * Update tripleo-quickstart from branch 'master' - [install-deps]Install "virtualenv<20.0.1" New release of virtualenv broke the venv creation and started returni... — committed to openstack/openstack by chkumar246 4 years ago
- workaround https://github.com/pypa/virtualenv/issues/1551#issuecomment-584148133 — committed to sapcc/keystone by Carthaca 4 years ago
- work around pip/virtualenv dependency resolution bug https://github.com/pypa/virtualenv/issues/1551 — committed to liberapay/liberapay.com by Changaco 4 years ago
- build: Require six >= 0.1.14 New virtualenv version fails because pip dependency resolving is broken. Requiring newer version fix should avoid the issue, allowing using latest vitualenv. [1] https:/... — committed to nirs/ovirt-imageio by nirs 4 years ago
- Workaround for pip/virtualenv/tox issue See https://github.com/pypa/virtualenv/issues/1551 — committed to tonysimpson/acceptable by tonysimpson 4 years ago
- Moving to Travis stages because python various virtualenv were not being run with the correct Travis python version - Also pin virtualenv to be <20.0.0 because of https://github.com/pypa/virtualenv/is... — committed to lucagiovagnoli/mleap by lucagiovagnoli 4 years ago
- Moving to Travis stages because python various virtualenv were not being run with the correct Travis python version - Also pin virtualenv to be <20.0.0 because of https://github.com/pypa/virtualenv/is... — committed to lucagiovagnoli/mleap by lucagiovagnoli 4 years ago
- Moving to Travis stages because python various virtualenv were not being run with the correct Travis python version - Also pin virtualenv to be <20.0.0 because of https://github.com/pypa/virtualenv/is... — committed to lucagiovagnoli/mleap by lucagiovagnoli 4 years ago
- Moving to Travis stages because python various virtualenv were not being run with the correct Travis python version - Also pin virtualenv to be <20.0.0 because of https://github.com/pypa/virtualenv/is... — committed to lucagiovagnoli/mleap by lucagiovagnoli 4 years ago
- Update git submodules * Update devstack-gate from branch 'master' - Cap virtualenv to a version < 20 There are errors with the recently released virtualenv 20 for example: https://gith... — committed to openstack/openstack by gmannos 4 years ago
- Cap virtualenv to a version < 20 There are errors with the recently released virtualenv 20 for example: https://github.com/pypa/virtualenv/issues/1551 It has been capped on devstack side also I3b447... — committed to openstack/devstack-gate by gmannos 4 years ago
- Moving to Travis stages because python various virtualenv were not being run with the correct Travis python version - Also pin virtualenv to be <20.0.0 because of https://github.com/pypa/virtualenv/is... — committed to lucagiovagnoli/mleap by lucagiovagnoli 4 years ago
- Moving to Travis stages because python various virtualenv were not being run with the correct Travis python version - Also pin virtualenv to be <20.0.0 because of https://github.com/pypa/virtualenv/is... — committed to lucagiovagnoli/mleap by lucagiovagnoli 4 years ago
- Moving to Travis stages because python various virtualenv were not being run with the correct python version - pin virtualenv to be <20.0.0 because of https://github.com/pypa/virtualenv/issues/1551 - ... — committed to lucagiovagnoli/mleap by lucagiovagnoli 4 years ago
- Moving to Travis stages because python various virtualenv were not being run with the correct python version - pin virtualenv to be <20.0.0 because of https://github.com/pypa/virtualenv/issues/1551 - ... — committed to lucagiovagnoli/mleap by lucagiovagnoli 4 years ago
One fix would be to not depend on
ensure_texthere – almost all of the cases should usesix.text_type(...)anywayCan we please reopen this bug? The reality is that is perfectly possible to end-up with a newer virtualenv with a six version that is too old.
Here is an example: https://logserver.rdoproject.org/16/24916/5/check/check-centos-8/595187c/job-output.txt
this seems pretty bad 😕
here’s a minimal reproduction:
and now my users are complaining to me about it: https://github.com/pre-commit/pre-commit/issues/1325
We worked around the problem with
pip install tox "six>=1.14.0". Seems to be a pip issue with resolving depdencies to me, maybe https://github.com/pypa/pip/issues/988fwiw this was suggested during the feedback period here: https://github.com/pypa/virtualenv/pull/1481#discussion_r363314464