[Python3] virtualenv | pipenv : errors ✔
#1

Bonjour

J'essaye de comprendre cette histoire d'environnement virtuel.
(ayant toujours ma serviette avec moi... je lis cette doc, ou celle-ci)

Bref, lors de l'exécution de l'environnement virtuel, je me retrouve avec cette erreur dont je ne comprend pas la raison :

Code :
$ virtualenv mybeautifullproject                                            
Using base prefix '/usr/local'
New python executable in $HOME/Prog/env.py/mybeautifullproject.py/mybeautifullproject/bin/python3
Also creating executable in $HOME/Prog/env.py/mybeautifullproject.py/mybeautifullproject/bin/python
ERROR: The executable $HOME/Prog/env.py/mybeautifullproject.py/mybeautifullproject/bin/python3 could not be run: [Errno 13] Permission denied: '$HOME/Prog/env.py/mybeautifullproject.py/mybeautifullproject/bin/python

Code :
$ ls -al mybeautifullproject/                                                
total 40
drwxr-xr-x  5 hs  hs  512 Jun  3 01:43 ./
drwxr-xr-x  3 hs  hs  512 Jun  3 01:44 ../
drwxr-xr-x  2 hs  hs  512 Jun  3 01:43 bin/
drwxr-xr-x  2 hs  hs  512 Jun  3 01:43 include/
drwxr-xr-x  3 hs  hs  512 Jun  3 01:43 lib/

Code :
$ ls -al mybeautifullproject/bin/                                            
total 40
drwxr-xr-x  2 hs  hs    512 Jun  3 01:43 ./
drwxr-xr-x  5 hs  hs    512 Jun  3 01:43 ../
lrwxr-xr-x  1 hs  hs      7 Jun  3 01:43 python@ -> python3
-rwxr-xr-x  1 hs  hs  10680 Jun  3 01:43 python3*
lrwxr-xr-x  1 hs  hs      7 Jun  3 01:43 python3.6@ -> python3

Une idée ?

(au cas où j'ai essayé virtualenvwrapper - mais c'est pour bash - pfff)



Idem avec pipenv :

Code :
$ pipenv install requests
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project…
Pipfile: $HOME/Prog/env.py/mybeautifullproject.py/Pipfile
Using /usr/local/bin/python3 (3.6.8) to create virtualenv…
⠇ Creating virtual environment...Already using interpreter /usr/local/bin/python3
Using base prefix '/usr/local'
New python executable in $HOME/.local/share/virtualenvs/mybeautifullproject.py-oFlnu9vD/bin/python3
Also creating executable in $HOME/.local/share/virtualenvs/mybeautifullproject.py-oFlnu9vD/bin/python
ERROR: The executable $HOME/.local/share/virtualenvs/mybeautifullproject.py-oFlnu9vD/bin/python3 could not be run: [Errno 13] Permission denied: '$HOME/.local/share/virtualenvs/mybeautifullproject.py-oFlnu9vD/bin/python3'

✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:   File "$HOME/.local/lib/python3.6/site-packages/pipenv/cli/command.py", line 254, in install
[pipenv.exceptions.VirtualenvCreationException]:       editable_packages=state.installstate.editables,
[pipenv.exceptions.VirtualenvCreationException]:   File "$HOME/.local/lib/python3.6/site-packages/pipenv/core.py", line 1741, in do_install
[pipenv.exceptions.VirtualenvCreationException]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "$HOME/.local/lib/python3.6/site-packages/pipenv/core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "$HOME/.local/lib/python3.6/site-packages/pipenv/core.py", line 506, in ensure_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]:   File "$HOME/.local/lib/python3.6/site-packages/pipenv/core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.


Bref, je ne sais quoi trop en penser ?!

Ici, on parle de l'option 'exec' sur le mount de home qui pourrait résoudre...
Ailleurs, on mentionne les droits... mais je suis dans mon home, exécuté avec mes droits, et pas ceux d'admin !

GPG:Fingerprint ed25519 : 072A 4DA2 8AFD 868D 74CF  9EA2 B85E 9ADA C377 5E8E
GPG:Fingerprint rsa4096 : 4E0D 4AF7 77F5 0FAE A35D  5B62 D0FF 7361 59BF 1733
Répondre
#2

Purée, grâce à Xavier, de manière indirecte, il m'a donné la réponse :
C'est la "faute" à la protection W^X Wink

Bref, de fait, pour que ça fonctionne :

-> Direction vers /usr/local, pour création d'un dossier personnel :

Code :
# mkdir -p /usr/local/${my_user}/python
# chown -R ${my_user}:wheel /usr/local/${my_user}
# ln -s /usr/local/${my_user}/python $home/python

Résultat :
Code :
$ virtualenv mybeautifullproject
Using base prefix '/usr/local'
New python executable in /usr/local/hs/python/mybeautifullproject/bin/python3
Also creating executable in /usr/local/hs/python/mybeautifullproject/bin/python
Installing setuptools, pip, wheel...
done.


Pour la commande "pipenv", il faut rajouter une création :

Code :
$ mkdir /usr/local/$USER/python/virtualenvs
$ ln -s /usr/local/$USER/python/virtualenvs $HOME/.local/share/virtualenvs

Résultat :
Code :
$ pipenv install requests
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project…
Pipfile: /usr/local/hs/python/mybeautifullproject/Pipfile
Using /usr/local/bin/python3 (3.6.8) to create virtualenv…
⠹ Creating virtual environment...Already using interpreter /usr/local/bin/python3
Using base prefix '/usr/local'
New python executable in /home/hs/.local/share/virtualenvs/mybeautifullproject-q1koN8ay/bin/python3
Also creating executable in /home/hs/.local/share/virtualenvs/mybeautifullproject-q1koN8ay/bin/python
Installing setuptools, pip, wheel...
done.

✔ Successfully created virtual environment!
Virtualenv location: /home/hs/.local/share/virtualenvs/mybeautifullproject-q1koN8ay
Creating a Pipfile for this project…
Installing requests…
Adding requests to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (b14837)!
Installing dependencies from Pipfile.lock (b14837)…
  ?  ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 — 00:00:14
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

Well-done!

Je vais enfin pouvoir faire mumuse avec les environnements Python !!!

Yesss

GPG:Fingerprint ed25519 : 072A 4DA2 8AFD 868D 74CF  9EA2 B85E 9ADA C377 5E8E
GPG:Fingerprint rsa4096 : 4E0D 4AF7 77F5 0FAE A35D  5B62 D0FF 7361 59BF 1733
Répondre
#3

De rien, je l'ai fait exprès bien sûr  Hippie
Répondre
#4

Page wiki : https://wiki.obsd4a.net/tips:python

GPG:Fingerprint ed25519 : 072A 4DA2 8AFD 868D 74CF  9EA2 B85E 9ADA C377 5E8E
GPG:Fingerprint rsa4096 : 4E0D 4AF7 77F5 0FAE A35D  5B62 D0FF 7361 59BF 1733
Répondre
#5

Bon, j'ai un nouveau problème :

à un environnement test, je tente une mise à jour qui se passe bien :
Code :
$ pipenv update
Running $ pipenv lock then $ pipenv sync.
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (ca72e7)!
Installing dependencies from Pipfile.lock (ca72e7)…
  ?   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
Je ferme ledit environnement de test et bascule sur un environnement pour un de mes projets, et je veux appliquer la même action :
Code :
$ pipenv update
Running $ pipenv lock then $ pipenv sync.
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed!
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches motify2
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches motify2
No versions found
Was https://pypi.org/simple reachable?
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches motify2
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches motify2
No versions found
Was https://pypi.org/simple reachable?
Étonnant, non !?
Qu'est-ce qui peut bien clocher ?

----

Bon, ok, j'ai détruit l'environnement en question, et l'ai reconstruit, ni plus ni moins. (certainement du fait que sous 6.5, c'était python 3.6.6, et maintenant sous 6.6, c'est python 3.7.4)

GPG:Fingerprint ed25519 : 072A 4DA2 8AFD 868D 74CF  9EA2 B85E 9ADA C377 5E8E
GPG:Fingerprint rsa4096 : 4E0D 4AF7 77F5 0FAE A35D  5B62 D0FF 7361 59BF 1733
Répondre


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)