Virtualenv: Erreur Virtualenv 20.0.0b1 lors de la création de venv pour brew python2

Créé le 28 janv. 2020  ·  10Commentaires  ·  Source: pypa/virtualenv

Sur mon Mac avec Homebrew Python2 (et 3) :

$ ls -al $(which python2)
lrwxr-xr-x  1 brettmz  admin  37 Nov 15 12:04 /usr/local/bin/python2 -> ../Cellar/python@2/2.7.17/bin/python2

Je reçois:

$ virtualenv --python /usr/local/bin/python2 py2env
Traceback (most recent call last):
  File "/Users/brettmz/Library/Python/3.7/bin/virtualenv", line 8, in <module>
    sys.exit(run())
  File "/Users/brettmz/Library/Python/3.7/lib/python/site-packages/virtualenv/__main__.py", line 16, in run
    run_via_cli(args)
  File "/Users/brettmz/Library/Python/3.7/lib/python/site-packages/virtualenv/run/__init__.py", line 21, in run_via_cli
    session = session_via_cli(args)
  File "/Users/brettmz/Library/Python/3.7/lib/python/site-packages/virtualenv/run/__init__.py", line 33, in session_via_cli
    raise RuntimeError("failed to find interpreter for {}".format(discover))
RuntimeError: failed to find interpreter for Builtin discover of python_spec='/usr/local/bin/python2'

Cela fonctionne sans erreur pour virtualenv stable actuel. Est-ce prévu ?

Commentaire le plus utile

Avec la version bêta non modifiée, cela fonctionne :

virtualenv --python=/usr/local/bin/python2.7 foo

Soit fonctionne avec votre branche discovery .

Merci pour votre réponse rapide.

Tous les 10 commentaires

@matthew-brett Je devrai valider, merci d'avoir porté cela à mon attention.

Hmmm, je ne peux pas reproduire ça 🤔 peux-tu poster la sortie avec -vvv ?

Sûr:

89 setup logging to NOTSET [DEBUG report:43]
161 find interpreter for spec PythonSpec(str_spec=/usr/local/bin/python2, path=/usr/local/bin/python2) [INFO builtin:44]
161 proposed PythonInfo(spec=CPython3.7.5.final.0-64, exe=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7, platform=darwin, version='3.7.5 (v3.7.5:5c02a39a0b, Oct 14 2019, 19:07:34) \n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]', encoding_fs_io=utf-8-UTF-8) [INFO builtin:48]
162 Attempting to acquire lock 4568075728 on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/480187601bdac08cce463831e50aade5e1a71f4acabcd8828b0a0dd3276fab64.lock [DEBUG filelock:270]
162 Lock 4568075728 acquired on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/480187601bdac08cce463831e50aade5e1a71f4acabcd8828b0a0dd3276fab64.lock [INFO filelock:274]
163 get PythonInfo from /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/480187601bdac08cce463831e50aade5e1a71f4acabcd8828b0a0dd3276fab64.json for /usr/local/bin/python2 [DEBUG cached_py_info:67]
163 Attempting to release lock 4568075728 on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/480187601bdac08cce463831e50aade5e1a71f4acabcd8828b0a0dd3276fab64.lock [DEBUG filelock:315]
163 Lock 4568075728 released on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/480187601bdac08cce463831e50aade5e1a71f4acabcd8828b0a0dd3276fab64.lock [INFO filelock:318]
163 proposed PythonInfo(spec=CPython2.7.17.final.0-64, exe=/usr/local/bin/python2.7, original=/usr/local/opt/python@2/bin/python2.7, platform=darwin, version='2.7.17 (default, Oct 24 2019, 12:57:38) \n[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8)]', encoding_fs_io=utf-8-None) [INFO builtin:48]
164 discover PATH[0]=/usr/local/opt/ruby/bin [DEBUG builtin:75]
164 discover PATH[1]=/Library/Frameworks/Python.framework/Versions/3.7/bin [DEBUG builtin:75]
164 discover PATH[2]=/Users/brettmz/usr/local/fsl/bin [DEBUG builtin:75]
165 discover PATH[3]=/Users/brettmz/Library/Python/3.7/bin [DEBUG builtin:75]
165 Attempting to acquire lock 4564090384 on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d.lock [DEBUG filelock:270]
165 Lock 4564090384 acquired on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d.lock [INFO filelock:274]
166 get PythonInfo from /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d.json for /Users/brettmz/Library/Python/3.7/bin/python [DEBUG cached_py_info:67]
166 Attempting to release lock 4564090384 on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d.lock [DEBUG filelock:315]
166 Lock 4564090384 released on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d.lock [INFO filelock:318]
166 proposed PythonInfo(spec=CPython3.7.5.final.0-64, exe=/Users/brettmz/Library/Python/3.7/bin/python, platform=darwin, version='3.7.5 (v3.7.5:5c02a39a0b, Oct 14 2019, 19:07:34) \n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]', encoding_fs_io=utf-8-UTF-8) [INFO builtin:48]
167 discover PATH[4]=/usr/sbin [DEBUG builtin:75]
167 discover PATH[5]=/sbin [DEBUG builtin:75]
167 discover PATH[6]=/Users/brettmz/usr/bin [DEBUG builtin:75]
167 discover PATH[7]=/usr/local/bin [DEBUG builtin:75]
168 discover PATH[8]=/usr/bin [DEBUG builtin:75]
168 Attempting to acquire lock 4564099344 on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/aaafe28a6254581d4f0ccfa0911e2de9e463b78fe3b32b118542e908e534a6ec.lock [DEBUG filelock:270]
168 Lock 4564099344 acquired on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/aaafe28a6254581d4f0ccfa0911e2de9e463b78fe3b32b118542e908e534a6ec.lock [INFO filelock:274]
168 get PythonInfo from /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/aaafe28a6254581d4f0ccfa0911e2de9e463b78fe3b32b118542e908e534a6ec.json for /usr/bin/python [DEBUG cached_py_info:67]
169 Attempting to release lock 4564099344 on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/aaafe28a6254581d4f0ccfa0911e2de9e463b78fe3b32b118542e908e534a6ec.lock [DEBUG filelock:315]
169 Lock 4564099344 released on /Users/brettmz/Library/Application Support/virtualenv/py-info/20.0.0b1/aaafe28a6254581d4f0ccfa0911e2de9e463b78fe3b32b118542e908e534a6ec.lock [INFO filelock:318]
169 proposed PythonInfo(spec=CPython2.7.16.final.0-64, exe=/usr/bin/python, original=/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python, platform=darwin, version='2.7.16 (default, Nov  9 2019, 05:55:08) \n[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s', encoding_fs_io=utf-8-None) [INFO builtin:48]
169 discover PATH[9]=/bin [DEBUG builtin:75]
169 discover PATH[10]=/usr/sbin [DEBUG builtin:75]
169 discover PATH[11]=/sbin [DEBUG builtin:75]
170 discover PATH[12]=/Library/TeX/texbin [DEBUG builtin:75]
170 discover PATH[13]=/opt/X11/bin [DEBUG builtin:75]
170 done in 82ms [INFO __main__:23]
Traceback (most recent call last):
  File "/Users/brettmz/Library/Python/3.7/bin/virtualenv", line 8, in <module>
    sys.exit(run())
  File "/Users/brettmz/Library/Python/3.7/lib/python/site-packages/virtualenv/__main__.py", line 16, in run
    run_via_cli(args)
  File "/Users/brettmz/Library/Python/3.7/lib/python/site-packages/virtualenv/run/__init__.py", line 21, in run_via_cli
    session = session_via_cli(args)
  File "/Users/brettmz/Library/Python/3.7/lib/python/site-packages/virtualenv/run/__init__.py", line 33, in session_via_cli
    raise RuntimeError("failed to find interpreter for {}".format(discover))
RuntimeError: failed to find interpreter for Builtin discover of python_spec='/usr/local/bin/python2'

Cette partie semble l'information pertinente :
```
161 find interpréteur pour spec PythonSpec(str_spec=/usr/local/bin/python2, path=/usr/local/bin/python2) [INFO builtin:44 ]

163 get PythonInfo de / Utilisateurs / brettmz / Bibliothèque / Application Support / virtualenv / py-info / 20.0.0b1 / 480187601bdac08cce463831e50aade5e1a71f4acabcd8828b0a0dd3276fab64.json pour / usr / bin local / / python2 [DEBUG cached_py_ info: 67 ]

163 proposé PythonInfo (spec = CPython2.7.17.final.0-64, exe = / usr / local / bin / python2.7, original = / usr / local / opt / python@2/bin/python2.7 , plate - forme = darwin, version='2.7.17 (par défaut, 24 octobre 2019, 12:57:38) \n[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8)]', encoding_fs_io=utf-8- Aucun) [INFO intégré:48 ]
````

On dirait que /usr/local/bin/python2 traduit par /usr/local/bin/python2.7 ... Qu'est-ce que /usr/local/bin/python2.7 pointe aussi ?

Il donne:

$ ls -al /usr/local/bin/python2.7
lrwxr-xr-x  1 brettmz  admin  39 Nov 15 12:04 /usr/local/bin/python2.7 -> ../Cellar/python@2/2.7.17/bin/python2.7

Démarrer l'interpréteur directement avec /usr/local/bin/python2 fonctionne bien, mais je suppose que cela découle du fait qu'il fonctionne à partir de virtualenv plus ancien.

$ /usr/local/bin/python2
Python 2.7.17 (default, Oct 24 2019, 12:57:38) 
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Je pense que https://github.com/pypa/virtualenv/pull/1513 corrigera cela si vous pouvez l'essayer

Pour être juste, le bon test ici serait d'essayer de créer un python d'abord avec /usr/local/bin/python2.7 puis /usr/local/bin/python2 ... et les deux devraient fonctionner.

Je pense que https://github.com/pypa/virtualenv/pull/1513 a résolu ce problème, du moins selon mes tests, sinon, n'hésitez pas à faire rapport et nous rouvrirons le problème.

Avec la version bêta non modifiée, cela fonctionne :

virtualenv --python=/usr/local/bin/python2.7 foo

Soit fonctionne avec votre branche discovery .

Merci pour votre réponse rapide.

Merci d'avoir pris le temps de tester la nouvelle version

thanks

Cette page vous a été utile?
0 / 5 - 0 notes