121 lines
2.2 KiB
Markdown
121 lines
2.2 KiB
Markdown
# Python 3
|
||
|
||
|
||
|
||
Python 3 peut s'installer avec Homebrew:
|
||
|
||
```bash
|
||
$ brew install python3
|
||
```
|
||
|
||
Les extensions Python 3 s'installent dans `/usr/local/lib/python3.6/site-packages/`
|
||
|
||
Pour lancer un script Python 3:
|
||
|
||
```bash
|
||
$ python3 script.py
|
||
```
|
||
|
||
|
||
|
||
Pour que python pointe sur Python 3 (homebrew), rajouter ceci à .bash_profile:
|
||
|
||
```bash
|
||
export PATH=/usr/local/opt/python/libexec/bin:$PATH
|
||
```
|
||
|
||
|
||
|
||
Pip est installé d'origine avec Python 3. On le lance avec la commande **pip3**:
|
||
|
||
```bash
|
||
$ pip3 list --outdated --format=columns
|
||
$ pip3 install mkdocs
|
||
```
|
||
|
||
|
||
|
||
Installation utilisateur:
|
||
|
||
```bash
|
||
$ python3 -m site --user-base
|
||
/Users/bruno/Library/Python/3.6
|
||
```
|
||
|
||
[Pipenv](https://docs.pipenv.org)
|
||
|
||
|
||
|
||
### Modules:
|
||
|
||
#### Mkdocs
|
||
|
||
Mkdocs si'installe dans `/usr/local/bin` :
|
||
|
||
```bash
|
||
bruno@silverbook:/usr/local/bin$ ./mkdocs --version
|
||
mkdocs, version 0.17.2
|
||
```
|
||
|
||
Par défaut, c'est **mkdocs** installé avec Python 2 (macOS) qui se lance.
|
||
|
||
Pour utiliser **mkdocs** installé pour Python 3 (Homebrew):
|
||
|
||
```bash
|
||
bruno@silverbook:~/project$ /usr/local/bin/mkdocs serve
|
||
```
|
||
|
||
|
||
|
||
Par comparaison, les extensions Python 2 s'installent dans `/Library/Python/2.7/site-packages/`
|
||
|
||
**Mkdocs** si'installe dans `~/Library/Python/2.7/bin` :
|
||
|
||
```bash
|
||
bruno@silverbook:~/Library/Python/2.7/bin$ ./mkdocs --version
|
||
mkdocs, version 0.17.2
|
||
```
|
||
|
||
|
||
|
||
#### Django
|
||
|
||
[Installer Django](Django.md)
|
||
|
||
|
||
|
||
#### Rechercher un module
|
||
|
||
[PyPI - the Python Package Index](https://pypi.python.org/pypi)
|
||
|
||
|
||
|
||
#### Problème à l'installation
|
||
|
||
Erreur lors de l’install de python3 avec Homebrew:
|
||
|
||
```bash
|
||
bruno@HackiMac:/usr/local/bin$ brew install python3
|
||
|
||
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.0.high_sierra.bottle.3.tar.gz
|
||
|
||
Already downloaded: /Users/bruno/Library/Caches/Homebrew/downloads/d76c2354ae237f190a868bb74f28d606b88cce724222bafa114e91cd8a1462d5--python-3.7.0.high_sierra.bottle.3.tar.gz
|
||
|
||
==> Pouring python-3.7.0.high_sierra.bottle.3.tar.gz
|
||
|
||
Error: An unexpected error occurred during the `brew link` step
|
||
The formula built, but is not symlinked into /usr/local
|
||
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
|
||
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
|
||
|
||
|
||
```
|
||
|
||
Solution:
|
||
|
||
```bash
|
||
sudo mkdir /usr/local/Frameworks
|
||
sudo chown $(whoami):admin /usr/local/Frameworks
|
||
```
|
||
|