issue148:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue148:python [2019/09/09 07:39] – d52fr | issue148:python [2019/09/17 15:38] (Version actuelle) – lecastillan | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
**Last month, I talked about Python 3.8.0b2 and I suggested that if you wanted to try it, you should consider a virtual environment. I then realized that I hadn't really discussed virtual environments before. So, I'm going to now.** | **Last month, I talked about Python 3.8.0b2 and I suggested that if you wanted to try it, you should consider a virtual environment. I then realized that I hadn't really discussed virtual environments before. So, I'm going to now.** | ||
- | Le mois dernier, j'ai parlé de Python 3.80b2 et j'ai suggéré que, si vous voulez | + | Le mois dernier, j'ai parlé de Python 3.8.0b2 et j'ai suggéré que, si vous vouliez |
**What is a Python Virtual Environment? | **What is a Python Virtual Environment? | ||
Ligne 9: | Ligne 9: | ||
Qu' | Qu' | ||
- | En gros, il vous permet de gérer facilement des versions multiples de Python (et de pip), sans mélanger | + | En gros, il vous permet de gérer facilement des versions multiples de Python (et de pip), sans semer la pagaille dans les paquets et les configurations que vous avez déjà. Pourquoi auriez-vous plusieurs configurations de Python ? Je sais que mon environnement est probablement quelque peu éloigné de vos besoins, mais j'ai plusieurs machines et, sur chacune, ma version « principale » de Python |
**What' | **What' | ||
Ligne 17: | Ligne 17: | ||
Quelle est la solution ? | Quelle est la solution ? | ||
- | J'ai trouvé un projet appelé pyenv qui fait plutôt bien tout ce dont vous avez besoin sans trop de peine. Vous pouvez le trouver sur https:// | + | J'ai trouvé un projet appelé pyenv qui fait plutôt bien tout ce dont vous avez besoin sans trop de peine. Vous pouvez le trouver sur https:// |
**Getting Started | **Getting Started | ||
Ligne 25: | Ligne 25: | ||
There are two ways to install pyenv. There is an easy way and a hard way. I'm going to discuss the easy way. The reason for this is that the easy way not only installs pyenv, but also installs some other pyenv tools that will be helpful – like pyenv-virtualenv, | There are two ways to install pyenv. There is an easy way and a hard way. I'm going to discuss the easy way. The reason for this is that the easy way not only installs pyenv, but also installs some other pyenv tools that will be helpful – like pyenv-virtualenv, | ||
- | Démarrage | + | Mise en route |
- | Je limiterai mes instructions à celles pour un PC utilisant Ubuntu/ | + | Je limiterai mes instructions à celles pour un PC utilisant Ubuntu/ |
- | Il y a deux façons d' | + | Il y a deux façons d' |
**The first thing you need to do is install the dependencies. You probably have most of them, but run the install command below just to be safe. Open a terminal and enter... | **The first thing you need to do is install the dependencies. You probably have most of them, but run the install command below just to be safe. Open a terminal and enter... | ||
Ligne 43: | Ligne 43: | ||
$ curl https:// | $ curl https:// | ||
- | La première chose que vous avez besoin de faire est d' | + | La première chose que vous devez faire est d' |
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ | sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ | ||
Ligne 67: | Ligne 67: | ||
Make sure that the first line defining the PYENV_ROOT points to the correct directory.** | Make sure that the first line defining the PYENV_ROOT points to the correct directory.** | ||
- | Ceci lance l' | + | Cela lance l' |
$ source ~/.bashrc | $ source ~/.bashrc | ||
- | Vous avez besoin, ensuite, de modifier le fichier .bashrc. Si vous utilisez une version différente, | + | Vous avez besoin, ensuite, de modifier le fichier .bashrc. Si vous utilisez une version différente, |
$ gedit ~/.bashrc | $ gedit ~/.bashrc | ||
Ligne 91: | Ligne 91: | ||
$ pyenv install --list** | $ pyenv install --list** | ||
- | Sauvegardez votre fichier .bashrc et rechargez-le. Comme précédemment, | + | Sauvegardez votre fichier .bashrc et rechargez-le. Comme précédemment, |
$ source ~/.bashrc | $ source ~/.bashrc | ||
- | Ceci force le rechergement | + | Cela force le rechargement |
$ pyenv update | $ pyenv update | ||
Ligne 121: | Ligne 121: | ||
* 3.7.4 (set by / | * 3.7.4 (set by / | ||
- | Vous obtiendrez ainsi une liste de tous les paquets disponibles que vous pouvez installer. C'est une TRÉS longue liste, avec les versions | + | Vous obtiendrez ainsi une liste de tous les paquets disponibles que vous pouvez installer. C'est une TRÉS longue liste, avec les versions actuelles |
- | Pour l' | + | Pour l' |
$ pyenv install 3.7.4 | $ pyenv install 3.7.4 | ||
- | Ça prend environ cinq minutes sur mon vieux portable ; aussi, allez prendre | + | Ça prend environ cinq minutes sur mon vieux portable ; aussi, allez prendre |
- | une fois l' | + | Une fois l' |
$ pyenv versions | $ pyenv versions | ||
Ligne 149: | Ligne 149: | ||
$ ls ~/ | $ ls ~/ | ||
- | Plusieurs choses à noter ici. D' | + | Plusieurs choses à noter ici. D' |
$ python -V | $ python -V | ||
Ligne 155: | Ligne 155: | ||
Vous devriez voir la version que vous utilisez normalement. | Vous devriez voir la version que vous utilisez normalement. | ||
- | Actuellement, | + | Bon. Vous pouvez toujours voir les versions que pyenv a installées, en faisant ceci : |
$ ls ~/ | $ ls ~/ | ||
Ligne 175: | Ligne 175: | ||
$ pyenv local 3.7.4** | $ pyenv local 3.7.4** | ||
- | C'est là que sont situées toutes les versions de Python | + | C'est là que sont situées toutes les versions de python |
rm -rf ~/ | rm -rf ~/ | ||
- | dans une fenêtre de terminal. Par exemple, si je voulais | + | dans une fenêtre de terminal. Par exemple, si je voulais |
$ rm -rf ~/ | $ rm -rf ~/ | ||
- | Ou, vous pouvez le faire avec une commande de pyenv : | + | Ou vous pouvez le faire avec une commande de pyenv : |
$ pyenv uninstall 3.7.4 | $ pyenv uninstall 3.7.4 | ||
- | Mains ne le faites pas encore. Disons à pyenv que nous voulons utiliser la version 3.7.4 que vous venons | + | Mais ne le faites pas encore. Disons à pyenv que nous voulons utiliser la version 3.7.4 que nous venons d' |
$ pyenv local 3.7.4 | $ pyenv local 3.7.4 | ||
Ligne 206: | Ligne 206: | ||
$ python -V** | $ python -V** | ||
- | Demandez maintenant à python | + | Demandez maintenant à python la version |
$ python -V | $ python -V | ||
- | Vous devriez voir quelque chose comme ça... | + | Vous devriez voir quelque chose comme ceci... |
Python 3.7.4 | Python 3.7.4 | ||
Ligne 216: | Ligne 216: | ||
Sinon, essayez de faire « exec $SHELL », puis réessayez. | Sinon, essayez de faire « exec $SHELL », puis réessayez. | ||
- | Maintenant, juste pour que ce reste correct, revenez à la version du système. | + | Histoire de bien comprendre, revenez |
$ pyenv local system | $ pyenv local system | ||
$ python -V | $ python -V | ||
- | |||
**You should see your normal Python instance restored. Now, let's install the latest version of 3.8.0 in pyenv (which, at this writing, is 3.8.0b2). | **You should see your normal Python instance restored. Now, let's install the latest version of 3.8.0 in pyenv (which, at this writing, is 3.8.0b2). | ||
Ligne 304: | Ligne 303: | ||
Requirement already satisfied: setuptools in / | Requirement already satisfied: setuptools in / | ||
Requirement already satisfied: pip in / | Requirement already satisfied: pip in / | ||
+ | |||
+ | Vous pourriez recevoir aussi un message vous demandant de mettre pip à jour. Allez-y ; faîtes-le si vous voulez et ensuite nous paramétrerons un environnement virtuel. | ||
+ | |||
+ | Notez que nous utilisons « pip » et non « pip3 ». Que vous utilisiez l'un ou l' | ||
+ | |||
+ | Maintenant, nous allons traiter l' | ||
+ | |||
+ | $ pyenv virtualenv 3.8-dev 38beta | ||
+ | |||
+ | et la réponse devrait être quelque chose comme ça : | ||
+ | |||
+ | Looking in links: / | ||
+ | Requirement already satisfied: setuptools in / | ||
+ | Requirement already satisfied: pip in / | ||
**Now we want to activate our virtual environment | **Now we want to activate our virtual environment | ||
Ligne 315: | Ligne 328: | ||
The first thing you should notice is the (38beta) that appears before your prompt. This lets you know that you are now in the virtual environment 38beta. Next, notice the warning notice above. This says that the prompt change will be going away in some future version. Many users are trying to get the maintainers of pyenv to change their minds, since this can tell you what, if any, virtual environment you are using just at a glance.** | The first thing you should notice is the (38beta) that appears before your prompt. This lets you know that you are now in the virtual environment 38beta. Next, notice the warning notice above. This says that the prompt change will be going away in some future version. Many users are trying to get the maintainers of pyenv to change their minds, since this can tell you what, if any, virtual environment you are using just at a glance.** | ||
+ | |||
+ | Maintenant nous voulons activer notre environnement virtuel : | ||
+ | |||
+ | $ pyenv activate 38beta | ||
+ | |||
+ | Vous devriez obtenir : | ||
+ | |||
+ | pyenv-virtualenv: | ||
+ | (38beta) greg@greg-Latitude-E5500: | ||
+ | |||
+ | La première chose que vous devez noter, c'est le (38beta) qui apparaît avant votre invite. Cela vous permet de savoir que vous êtes maintenant dans l' | ||
**Now, verify you are using the correct python version… | **Now, verify you are using the correct python version… | ||
Ligne 331: | Ligne 355: | ||
This should reset the prompt back to its " | This should reset the prompt back to its " | ||
+ | |||
+ | Maintenant vérifiez que vous utilisez la bonne version de python... | ||
+ | |||
+ | $ python -V | ||
+ | Python 3.8.0b2+ | ||
+ | |||
+ | Et vérifiez que la version de pip pointe sur la bonne installation de python... | ||
+ | |||
+ | (38beta) greg@greg-Latitude-E5500: | ||
+ | pip 19.1.1 from / | ||
+ | |||
+ | Pour sortir de l' | ||
+ | |||
+ | $ pyenv deactivate | ||
+ | |||
+ | Cela remettra l' | ||
**At this point, you should now be able to move around using different Python versions pretty easily, activate and deactivate your virtual environments, | **At this point, you should now be able to move around using different Python versions pretty easily, activate and deactivate your virtual environments, | ||
Ligne 346: | Ligne 386: | ||
3.8.0 final: Monday, 2019-10-21** | 3.8.0 final: Monday, 2019-10-21** | ||
- | **If you want to keep up with the latest beta and release candidates within your pyenv world, when a new version is released, give it a day or two before you try to install | + | À ce stade, vous devriez être capable de passer d'une version de Python à une autre assez facilement, d' |
+ | |||
+ | Je dirais que, quoique vous fassiez, n' | ||
+ | |||
+ | 3.8.0 beta 3 : lundi 29-07-2019 | ||
+ | |||
+ | 3.8.0 beta 4 : lundi 26-08-2019 | ||
+ | |||
+ | 3.8.0 candidate 1 : lundi 30-09-2019 | ||
+ | |||
+ | 3.8.0 candidate 2 : lundi 07-10-2019 (si nécessaire) | ||
+ | |||
+ | 3.8.0 final : lundi 21-10-2019 | ||
+ | |||
+ | |||
+ | **If you want to keep up with the latest beta and release candidates within your pyenv world, when a new version is released, give it a day or two before you try to nstall | ||
+ | |||
+ | Si vous voulez vous tenir au courant des dernières RC (release candidiate - pré-version) et bêta du monde pyenv, quand une nouvelle version sort, donnez-vous un jour ou deux avant d' | ||
issue148/python.1568007556.txt.gz · Dernière modification : 2019/09/09 07:39 de d52fr