Vous n'êtes pas identifié(e).
L'icône rouge permet de télécharger chaque page du wiki visitée au format
PDF et la grise au format ODT →
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
utilisateurs:hypathie:tutos:developpement-pyhon-utiliser-django [08/12/2015 10:26] Hypathie [Avant de commencer] |
utilisateurs:hypathie:tutos:developpement-pyhon-utiliser-django [08/12/2015 11:52] Hypathie [Configurations et installation de Django avec SQLite3] |
||
---|---|---|---|
Ligne 54: | Ligne 54: | ||
<code root>apt-get install python-doc python3-doc</code> | <code root>apt-get install python-doc python3-doc</code> | ||
+ | |||
+ | * pour utiliser pyenv | ||
+ | |||
+ | <code root>apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ | ||
+ | libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev</code> | ||
* Sans rapport avec le développement mais utilisé plus bas | * Sans rapport avec le développement mais utilisé plus bas | ||
Ligne 187: | Ligne 192: | ||
===== Configurations et installation de Django avec SQLite3===== | ===== Configurations et installation de Django avec SQLite3===== | ||
+ | |||
+ | ==== Installer Django dans un environnement virtuel avec pyenv==== | ||
+ | |||
+ | <code user>git clone https://github.com/yyuu/pyenv.git ~/.pyenv</code> | ||
+ | <code user>echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc</code> | ||
+ | |||
+ | <code user>echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc</code> | ||
+ | <code user>echo 'eval "$(pyenv init -)"' >> ~/.bashrc</code> | ||
+ | <code user>exec $SHELL</code> | ||
+ | <code user>pyenv</code> | ||
+ | <code retour>pyenv 20151124-16-g132179d | ||
+ | Usage: pyenv <command> [<args>] | ||
+ | |||
+ | Some useful pyenv commands are: | ||
+ | commands List all available pyenv commands | ||
+ | local Set or show the local application-specific Python version | ||
+ | global Set or show the global Python version | ||
+ | shell Set or show the shell-specific Python version | ||
+ | install Install a Python version using python-build | ||
+ | uninstall Uninstall a specific Python version | ||
+ | rehash Rehash pyenv shims (run this after installing executables) | ||
+ | version Show the current Python version and its origin | ||
+ | versions List all Python versions available to pyenv | ||
+ | which Display the full path to an executable | ||
+ | whence List all Python versions that contain the given executable | ||
+ | |||
+ | See `pyenv help <command>' for information on a specific command. | ||
+ | For full documentation, see: https://github.com/yyuu/pyenv#readme</code> | ||
+ | <code user>pyenv install 2.7.9</code> | ||
+ | <code user>pyenv install 3.4.3</code> | ||
+ | |||
+ | <note> | ||
+ | L'exécution des deux commandes précédentes est longue. Patience... | ||
+ | </note> | ||
+ | |||
+ | <code user>pyenv versions</code> | ||
+ | <code retour>* system (set by /home/hypathie/.pyenv/version) | ||
+ | 2.7.9 | ||
+ | 3.4.3</code> | ||
+ | | ||
+ | * les commandes pyenv | ||
+ | |||
+ | <code user>pyenv +lacommande</code> | ||
+ | |||
+ | * Avoir une liste des commandes pyenv | ||
+ | |||
+ | <code user>pyenv</code> | ||
+ | <code retour>Some useful pyenv commands are: | ||
+ | commands List all available pyenv commands | ||
+ | local Set or show the local application-specific Python version | ||
+ | global Set or show the global Python version | ||
+ | shell Set or show the shell-specific Python version | ||
+ | install Install a Python version using python-build | ||
+ | uninstall Uninstall a specific Python version | ||
+ | rehash Rehash pyenv shims (run this after installing executables) | ||
+ | version Show the current Python version and its origin | ||
+ | versions List all Python versions available to pyenv | ||
+ | which Display the full path to an executable | ||
+ | whence List all Python versions that contain the given executable | ||
+ | </code> | ||
+ | |||
+ | * Configurer la version du shell pyenv pour choisir sa version de python | ||
+ | - Pour que le shell utilise la version 2 installée plutôt | ||
+ | <code user>pyenv shell 2.7.9</code> | ||
+ | - Pour savoir quelle est la version de son shell | ||
+ | <code user>pyenv shell</code> | ||
+ | <code retour>2.7.9</code> | ||
+ | - version de python utilisée | ||
+ | <code user>python --version</code> | ||
+ | <code retour>Python 2.7.9</code> | ||
+ | - Depuis où ? | ||
+ | <code user> which python</code> | ||
+ | <code user>/home/hypathie/.pyenv/shims/python</code> | ||
+ | |||
+ | - Pour changer de version de python pour l'environnement virtuel, on fait la même chose avec la version | ||
+ | <code user>pyenv shell 3.4.3</code> | ||
+ | <code user>python --version</code> | ||
+ | <code retour>Python 3.4.3</code> | ||
+ | |||
+ | * Utiliser virtualenv avec pyenv | ||
+ | <code user>git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv</code> | ||
+ | <code user>echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc</code> | ||
+ | <code user>exec $SHELL</code> | ||
+ | |||
+ | * Créer un répertoire pour django | ||
+ | <code user>mkdir MonPython3Django</code> | ||
+ | <code user>cd MonPython3Django/</code> | ||
+ | <code user>pyenv shell 3.4.3</code> | ||
+ | <code user>python --version</code> | ||
+ | <code retour>Python 3.4.3</code> | ||
+ | <code user>pyenv virtualenv 1.8-3.4</code> | ||
+ | <code retour>Ignoring indexes: https://pypi.python.org/simple | ||
+ | Requirement already satisfied (use --upgrade to upgrade): setuptools in /home/hypathie/.pyenv/versions/3.4.3/envs/1.8-3.4/lib/python3.4/site-packages | ||
+ | Requirement already satisfied (use --upgrade to upgrade): pip in /home/hypathie/.pyenv/versions/3.4.3/envs/1.8-3.4/lib/python3.4/site-packages | ||
+ | </code> | ||
+ | |||
+ | Pas d'erreur cette fois 8-) | ||
+ | <code user></code> | ||
+ | <code user></code> | ||
==== Installer Django dans un environnement python virtuel ==== | ==== Installer Django dans un environnement python virtuel ==== | ||
- | === On créer un répertoire par exemple sur son bureau :=== | + | === On créer un répertoire=== |
<code user>virtualenv MonPy3Django -p /usr/bin/python3.4</code> | <code user>virtualenv MonPy3Django -p /usr/bin/python3.4</code> |