|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
--- |
|
|
|
|
title: Running python scripts using different package versions |
|
|
|
|
tags: [python, pacman, pip, venv, script, shell, bash, AUR] |
|
|
|
|
updated: 2019-11-10 17:05 |
|
|
|
|
tags: [python, python3, pacman, pip, venv, script, shell, bash, AUR] |
|
|
|
|
updated: 2019-12-10 19:53 |
|
|
|
|
description: A couple of ways to prevent file conflicts on python packages and run scripts without package version problems |
|
|
|
|
--- |
|
|
|
|
|
|
|
|
@ -14,7 +14,7 @@ are easy to come out.
|
|
|
|
|
|
|
|
|
|
<!--more--> |
|
|
|
|
|
|
|
|
|
This problem stands out especially when using Python packages |
|
|
|
|
This problem stands out especially when using Python 3 packages |
|
|
|
|
installed from AUR because of their lack of maintenance. In this case |
|
|
|
|
I was tempted to run ``pip3 install ${PACKAGE}``... |
|
|
|
|
|
|
|
|
@ -51,7 +51,7 @@ installing a package using the root user (`# pip3 install "${PACKAGE_NAME}"`)
|
|
|
|
|
Install virtualenv and then create a new virtual environment: |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
python3 -m venv .local/venv/"${ENVIRONMENT_NAME}" |
|
|
|
|
python3 -m venv ~/.local/venv/"${ENVIRONMENT_NAME}" |
|
|
|
|
. ~/.local/venv/"${ENVIRONMENT_NAME}"/bin/activate |
|
|
|
|
pip3 install ${YOUR_PACKAGES} |
|
|
|
|
deactivate |
|
|
|
@ -65,7 +65,7 @@ you must call the virtual interpreter directly:
|
|
|
|
|
Finally, add the path of the virtual environment executables to |
|
|
|
|
the shell's path: |
|
|
|
|
|
|
|
|
|
export PATH=$PATH:~/.local/venv/"${ENVIRONMENT_NAME}"/bin |
|
|
|
|
export PATH=$PATH:$HOME/.local/venv/"${ENVIRONMENT_NAME}"/bin |
|
|
|
|
|
|
|
|
|
Reload your shell to be able to call a virtual environment executable directly. |
|
|
|
|
|
|
|
|
|