Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtualenv fails to create new environment with ImportError #2006

Closed
deadpyxel opened this issue Nov 5, 2020 · 3 comments
Closed

Virtualenv fails to create new environment with ImportError #2006

deadpyxel opened this issue Nov 5, 2020 · 3 comments
Labels

Comments

@deadpyxel
Copy link

deadpyxel commented Nov 5, 2020

Issue

When attempting to create a new environment via the command virtualenv venv I get the meassage

ImportError: cannot import name 'enquote_executable' from 'distlib.scripts' (/home/sidious/.local/lib/python3.8/site-packages/distlib/scripts.py)

At first I thought this was same or related to #1551 since the messages are similar, turns out that's not the case.

I noticed this after a recent update in the Archlinux package, on November 3rd, but after some testing, it seems I can reproduce the problem with any version from the Archlinux repo >= 20.0.25, as in the 20.0.25 (published in October 16) version works fine, but any above it will give me the same error.
This may be an Archlinux only problem, so I'm not really sure how to proceed.

I used ALA (Archlinux Archives) to test the multiple versions, found here: https://archive.archlinux.org/packages/p/python-virtualenv/

Environment

Provide at least:

  • OS: Archlinux kernel 5.9.3-arch1-1
  • pip list of the host python where virtualenv is installed:
Package                       Version          
----------------------------- -----------------
alabaster                     0.7.12           
anki                          2.1.26           
ankirspy                      2.1.26           
anytree                       2.8.0            
appdirs                       1.4.4            
apsw                          3.33.0.post1     
aqt                           2.1.26           
arandr                        0.1.10           
argcomplete                   1.11.1           
asn1crypto                    1.4.0            
astroid                       2.4.1            
attrs                         20.2.0           
autopep8                      1.5.4            
Babel                         2.8.0            
bcrypt                        3.2.0            
Beaker                        1.11.0           
beautifulsoup4                4.9.3            
beets                         1.4.9            
black                         19.10b0          
borgbackup                    1.1.14           
btrfsutil                     1.2.0            
bump2version                  1.0.1            
cached-property               1.5.2            
capstone                      4.0.1            
certifi                       2019.11.28       
cffi                          1.14.3           
cfgv                          3.2.0            
chardet                       3.0.4            
choosealicense-cli            1.1.0            
click                         7.1.2            
cmus-notify                   1.4.0            
colorama                      0.4.4            
commitizen                    2.4.0            
cryptography                  3.2.1            
css-parser                    1.0.6            
cssselect                     1.1.0            
decli                         0.5.2            
decorator                     4.4.2            
distlib                       0.3.0            
distro                        1.5.0            
dnspython                     2.0.0            
docker                        4.3.1            
docker-compose                1.27.4           
docker-pycreds                0.4.0            
dockerpty                     0.4.1            
docopt                        0.6.2            
docutils                      0.16             
dotdrop                       1.3.6            
feedparser                    5.2.1            
ffmulticonverter              1.8.0            
filebytes                     0.10.2           
filelock                      3.0.12           
flake8                        3.8.3            
gpapi                         0.4.4            
GPlayCli                      3.26             
greenlet                      0.4.16           
html2text                     2020.1.16        
html5-parser                  0.4.9            
html5lib                      1.1              
identify                      1.5.9            
idna                          2.10             
ifaddr                        0.1.7            
imagesize                     1.2.0            
importlib-metadata            2.0.0            
isc                           2.0              
isort                         4.3.21           
jedi                          0.17.2           
jellyfish                     0.8.2            
Jinja2                        2.11.2           
jsonschema                    3.2.0            
keystone-engine               0.9.1.post3      
keyutils                      0.6              
lazy-object-proxy             1.4.3            
lxml                          4.6.1            
Mako                          1.1.3            
mallard-ducktype              1.0.2            
Markdown                      3.3              
MarkupSafe                    1.1.1            
matlink-gpapi                 0.4.4.4          
mccabe                        0.6.1            
mechanize                     0.4.5            
msgpack                       1.0.0            
munkres                       1.1.2            
musicbrainzngs                0.7.1            
mutagen                       1.45.1           
neovim                        0.3.1            
netifaces                     0.10.9           
nodeenv                       1.5.0            
notify2                       0.3.1            
notmuch                       0.31             
notmuch2                      0.31             
ordered-set                   4.0.2            
packaging                     20.4             
paramiko                      2.7.2            
parso                         0.7.1            
pathspec                      0.8.0            
peewee                        3.13.3           
Pillow                        7.2.0            
pip                           19.3.1           
pipenv                        2020.11.4        
pluggy                        0.13.1           
ply                           3.11             
powerline-status              2.8.1            
pre-commit                    2.6.0            
prompt-toolkit                3.0.7            
protobuf                      3.12.4           
protonvpn-cli                 2.2.4            
psutil                        5.6.7            
pwquality                     1.4.4            
py                            1.9.0            
PyAudio                       0.2.11           
pyaxmlparser                  0.3.24           
pycairo                       1.20.0           
pychm                         0.8.6            
pycodestyle                   2.6.0            
pycparser                     2.20             
pyflakes                      2.2.0            
Pygments                      2.7.2            
PyGObject                     3.38.0           
pylint                        2.5.2            
PyNaCl                        1.4.0            
pynvim                        0.4.1            
pyparsing                     2.4.7            
PyQt5                         5.15.1           
PyQt5-sip                     12.8.1           
PyQtWebEngine                 5.15.1           
pyrsistent                    0.17.3           
python-dateutil               2.8.1            
python-dotenv                 0.15.0           
pythondialog                  3.5.1            
pytz                          2020.4           
pywal                         3.3.0            
pyxdg                         0.26             
PyYAML                        5.3.1            
questionary                   1.5.2            
Reflector                     2020.9.2.20.13.49
regex                         2020.10.15       
requests                      2.24.0           
ropper                        1.13.3           
ruamel.yaml                   0.16.12          
ruamel.yaml.clib              0.2.2            
Send2Trash                    1.5.0            
setuptools                    50.3.2           
six                           1.15.0           
snakeviz                      2.0.1            
snowballstemmer               2.0.0            
soupsieve                     2.0.1            
speedtest-cli                 2.1.2            
Sphinx                        3.2.1            
sphinxcontrib-applehelp       1.0.2            
sphinxcontrib-devhelp         1.0.2            
sphinxcontrib-htmlhelp        1.0.3            
sphinxcontrib-jsmath          1.0.1            
sphinxcontrib-qthelp          1.0.3            
sphinxcontrib-serializinghtml 1.1.4            
team                          1.0              
termcolor                     1.1.0            
texttable                     1.6.3            
tldr                          1.1.0            
toml                          0.10.2           
tomlkit                       0.5.11           
tornado                       6.0.4            
tox                           3.20.1           
typed-ast                     1.4.1            
udiskie                       2.2.0            
ufw                           0.36             
unicorn                       1.0.1            
Unidecode                     1.1.1            
unrardll                      0.1.4            
urllib3                       1.25.10          
virtualenv                    20.1.0           
virtualenv-clone              0.5.3            
wcwidth                       0.2.5            
webencodings                  0.5.1            
websocket-client              0.57.0           
wheel                         0.35.1           
wrapt                         1.12.1           
youtube-dl                    2020.11.1.1      
zeroconf                      0.28.6           
zipp                          3.4.0            

Output of the virtual environment creation

Make sure to run the creation with -vvv --with-traceback:

141 setup logging to NOTSET [DEBUG report:43]
236 find interpreter for spec PythonSpec(path=/usr/bin/python) [INFO builtin:51]
236 proposed PythonInfo(spec=CPython3.8.6.final.0-64, exe=/usr/bin/python, platform=linux, version='3.8.6 (default, Sep 30 2020, 04:00:38) \n[GCC 10.2.0]', encoding_fs_io=utf-8-utf-8) [INFO builtin:57]
236 accepted PythonInfo(spec=CPython3.8.6.final.0-64, exe=/usr/bin/python, platform=linux, version='3.8.6 (default, Sep 30 2020, 04:00:38) \n[GCC 10.2.0]', encoding_fs_io=utf-8-utf-8) [DEBUG builtin:59]
239 filesystem is case-sensitive [DEBUG info:28]
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 33, in <module>
    sys.exit(load_entry_point('virtualenv==20.1.0', 'console_scripts', 'virtualenv')())
  File "/usr/lib/python3.8/site-packages/virtualenv/__main__.py", line 62, in run_with_catch
    run(args, options)
  File "/usr/lib/python3.8/site-packages/virtualenv/__main__.py", line 16, in run
    session = cli_run(args, options)
  File "/usr/lib/python3.8/site-packages/virtualenv/run/__init__.py", line 26, in cli_run
    of_session = session_via_cli(args, options, setup_logging)
  File "/usr/lib/python3.8/site-packages/virtualenv/run/__init__.py", line 42, in session_via_cli
    parser, elements = build_parser(args, options, setup_logging)
  File "/usr/lib/python3.8/site-packages/virtualenv/run/__init__.py", line 69, in build_parser
    SeederSelector(interpreter, parser),
  File "/usr/lib/python3.8/site-packages/virtualenv/run/plugin/seeders.py", line 8, in __init__
    possible = self.options("virtualenv.seed")
  File "/usr/lib/python3.8/site-packages/virtualenv/run/plugin/base.py", line 39, in options
    cls._OPTIONS = cls.entry_points_for(key)
  File "/usr/lib/python3.8/site-packages/virtualenv/run/plugin/base.py", line 18, in entry_points_for
    return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
  File "/usr/lib/python3.8/site-packages/virtualenv/run/plugin/base.py", line 18, in <genexpr>
    return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
  File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 18, in <module>
    from .pip_install.copy import CopyPipInstall
  File "/usr/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/pip_install/copy.py", line 8, in <module>
    from .base import PipInstall
  File "/usr/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/pip_install/base.py", line 10, in <module>
    from distlib.scripts import ScriptMaker, enquote_executable
ImportError: cannot import name 'enquote_executable' from 'distlib.scripts' (/home/sidious/.local/lib/python3.8/site-packages/distlib/scripts.py)
@deadpyxel deadpyxel added the bug label Nov 5, 2020
@gaborbernat
Copy link
Contributor

Not sure how you installed virtualenv, but your install method failed to satisfy with success the install requirements:

https://github.com/pypa/virtualenv/blob/main/setup.cfg#L44 states we need at least distlib>=0.3.1,<1, but you only have distlib 0.3.0 (see https://pypi.org/project/distlib/0.3.1/#history). The issue is with your install method messing up.

@deadpyxel
Copy link
Author

distlib was automatically installed when I installed python-virtualenv, but if that's the issue I'll try to debug and find the problem with that install then. Thanks for the attention.

@gaborbernat
Copy link
Contributor

Then you should report the issue to the maintainer of python-virtualenv packaging.

@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants