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:17] Hypathie [Configurations et installation de Django avec SQLite3] |
utilisateurs:hypathie:tutos:developpement-pyhon-utiliser-django [08/12/2015 10:51] Hypathie [Configurations et installation de Django avec SQLite3] |
||
---|---|---|---|
Ligne 108: | Ligne 108: | ||
On choisit la sélection correspondante à python2.7 pour tout le système. Ici c'est le choix n°1. | On choisit la sélection correspondante à python2.7 pour tout le système. Ici c'est le choix n°1. | ||
+ | |||
+ | <note warning> | ||
+ | * À savoir pour supprimer l'un des choix de la liste : | ||
+ | |||
+ | <code root>update-alternatives --remove python /usr/bin/python2.7</code> | ||
+ | |||
+ | * Ne jamais désinstaller les versions inférieures à python 3 ! \\ De nombreux logiciels ne fonctionneraient plus. | ||
+ | |||
+ | ''<del>apt-get purge python</del>'' | ||
+ | </note> | ||
+ | |||
+ | * Pour vérifier | ||
<code root>python --version</code> | <code root>python --version</code> | ||
Ligne 113: | Ligne 125: | ||
<note tip> | <note tip> | ||
- | L'idée suivie ici sera de conserver python2 pour tout le système, et de mettre en place python3 dans un environnement virtuel. \\ | + | L'idée suivie ici sera de conserver python2 pour tout le système, et de mettre en place python3 dans un environnement virtuel consacré aux projets django. \\ |
- | Pour installer Django avec python3 y compris dans un environnement virtuel (dossier créé avec ''virtualenv'' dans le répertoire courant de l'utilisateur) , il faut d'abord que python3 soit en place afin de s'éviter quelque conflits lors de la création de son environnement virtuel python3 avec la commande ''virtualenv''. \\ | + | Pour installer Django avec python3 y compris **dans un environnement virtuel on n'utilisera pas** ''virtualenv'', afin de s'éviter quelque conflits lors de l'installation de django. \\ |
- | </note> | + | En effet : |
+ | <code user> | ||
+ | python --version | ||
+ | </code> | ||
+ | <code retour> | ||
+ | Python 3.4.2 | ||
+ | </code> | ||
+ | <code user>virtualenv MonPy3Django -p /usr/bin/python3.4</code> | ||
+ | <code user>cd MonPy3Django/</code> | ||
+ | <code user>source bin/activate 1.8-3.4</code> | ||
+ | <code retour>Downloading/unpacking django | ||
+ | Downloading Django-1.9-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded | ||
+ | Installing collected packages: django | ||
+ | *** Error compiling '/tmp/pip-build-c20d1nfa/django/django/conf/app_template/apps.py'... | ||
+ | File "/tmp/pip-build-c20d1nfa/django/django/conf/app_template/apps.py", line 4 | ||
+ | class {{ camel_case_app_name }}Config(AppConfig): | ||
+ | ^ | ||
+ | SyntaxError: invalid syntax | ||
- | <note warning> | + | *** Error compiling '/tmp/pip-build-c20d1nfa/django/django/conf/app_template/models.py'... |
- | * À savoir pour supprimer l'un des choix de la liste : | + | File "/tmp/pip-build-c20d1nfa/django/django/conf/app_template/models.py", line 1 |
+ | {{ unicode_literals }}from django.db import models | ||
+ | ^ | ||
+ | SyntaxError: invalid syntax | ||
- | <code root>update-alternatives --remove python /usr/bin/python2.7</code> | + | Successfully installed django |
- | + | Cleaning up... | |
- | * Ne jamais désinstaller les versions inférieures à python 3 ! \\ De nombreux logiciels ne fonctionneraient plus. | + | </code> |
- | ''<del>apt-get purge python</del>'' | ||
</note> | </note> | ||
+ | |||
+ | |||
Ligne 154: | Ligne 187: | ||
===== 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>. ~/.bashrc</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> | ||
+ | <code user></code> | ||
+ | <code user></code> | ||
+ | <code user></code> | ||
+ | <code user></code> | ||
+ | <code user></code> | ||
+ | <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> |