Table of Contents
Python Programming Related
This page hosts general information about python programming. For detailed packages, check the deligated pages. For example, Tensorflow Related.
Python environment management using conda
Miniconda Installation
We use conda
to manage package and virtual environment.
To learn about what is conda
: https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html
Also read the official ''conda'' documentations.
Check in your terminal if conda
has been installed, if not, you can either ask me to install it, or install it by yourself following the guides below.
Installation guides:
- We prefer to insall
miniconda
because it is ~480M, whileanaconda
is ~4.4GB. Check the difference between ''anaconda'' and ''miniconda''. - Install to the default place, whith is
/home/<username>/miniconda/
. - Following the official standard installation guide
- Or use this Quick Command Line Install.
Environment management:
PyCharm (IDE) Configurations
Conda, TensorFlow, LD_LIBRARY_PATH
Issue: Not setting environment parameters properly, so cannot find CUDA installation or some others
A workaround that uses just one line command and needs to manually configured for each environment:
# with the desired conda environment activated conda env config vars set LD_LIBRARY_PATH=$CONDA_PREFIX/lib
(credits: a GitHub issue discussion) Conda official documents about setting environment variables.
This has been a known issue of PyCharm for quite a long time. (For example: PyCharm doesn't set LD_LIBRARY_PATH when running scripts)
This allows the terminal to find Tensorflow
path correctly in the conda environment, but not PyCharm yet. See Configure PyCharm to run TensorFlow for additional settings.
Configure PyCharm to run TensorFlow
To use TensorFlow
properly, LD_LIBRARY_PATH
needs to be exposed to PyCharm properly. Within the correct conda env activated, find the correct path using:
echo $CONDA_PREFIX/lib
Then, add the output result as an environment variable LD_LIBRARY_PATH
in PyCharm.
- Edit
Run/Debug Configurations
, add an environment variable with the nameLD_LIBRARY_PATH
and the value of the output above.- With this, when the code is executed in
Run
panel, it detects the variable.
File | Settings | Build, Execution, Deployment | Console | Python Console
, add the same environment variable above.- With this, when the code is executed in
Python Console
panel, it detects the variable.