Python deployments: Difference between revisions
brief updates for 2017 |
No edit summary |
||
| Line 21: | Line 21: | ||
In the old days (2015) there were still debates about how to package Python and install stuff. Now, it's settled. Use pip. Easy_install is dead. See the [https://docs.python.org/3/installing/index.html docs]. Also note that <code>venv</code> is the successor to <code>virtualenv</code> | In the old days (2015) there were still debates about how to package Python and install stuff. Now, it's settled. Use pip. Easy_install is dead. See the [https://docs.python.org/3/installing/index.html docs]. Also note that <code>venv</code> is the successor to <code>virtualenv</code> | ||
== Basic PIP == | == Basic PIP and Virtual Environments == | ||
Do NOT (normally) use sudo with pip. Use a virtual environment | Do NOT (normally) use sudo with pip. Use a virtual environment. As of Python 3.4, the command is now called <code>pyvenv</code> or simply <code>venv</code>. As of Python 3.6 <code>pyvenv</code> is '''deprecated''' in favor of using <code>python3 -m venv</cod> to help prevent any potential confusion as to which Python interpreter a vritual environment will be based on. | ||
<source lang="bash"> | <source lang="bash"> | ||
$ | $ python3 -m venv myenv | ||
.. some output .. | .. some output .. | ||
$ source myenv/bin/activate | $ source myenv/bin/activate | ||
(myenv) $ pip install what-i-want | (myenv) $ pip install what-i-want | ||
# done using this python? | |||
deactivate | |||
</source> | </source> | ||
You only use sudo or elevated permissions when you want to install stuff for the global, system-wide Python installation. | You only use sudo or elevated permissions when you want to install stuff for the global, system-wide Python installation. | ||