Tag Archives: environment variable

The python version output from the command line is inconsistent with the python version in the current CONDA environment

Record a strange little problem.

         In order to complete the emotional dialogue project arranged by my tutor, I found a model from GitHub, and then configured the environment python2.7 + tensorflow1.13.1 on the server according to readme. At the beginning of training, I found that the training speed was very slow. After checking, I found that I didn’t use the GPU version of tensorflow, so I changed it to tensorflow-gpu1.13.1.

         Import error: libcublas. So. 10.0: cannot open shared object file: no such file or directory

         Very common old problem, CUDA is not installed or environment variables are not configured. I didn’t add CUDA to the environment variable here, because it’s a server in the school laboratory. It doesn’t have sudo permission and can’t modify the environment variable of the system, so I can only add the environment variable I need with the export command every time I start the terminal. For convenience, all the environment variables that need to be exported are recorded in a file. You only need the file source each time.

        After the source is completed, a strange problem appears. I output Python 3.8.5 with Python command in CONDA environment, and the python version of the environment shown in CONDA list is 2.7, as shown in the figure below. Clearly is the environment of Python 2.7, why use the python command to prompt that the current version is Python 3.8.5?I try to import tensorflow. It also prompts no module named tensorflow, which means that although it shows that I am in the dual RL master environment, I am in another environment?

         I repeatedly tried to delete the environment, create a new environment, and re install various packages. After many tests, I finally found the problem. When CONDA activate is executed, the target environment will be added to the environment variable of the current system, so when the python command is executed on the command line, the python version in the target environment will be executed. When the export command is executed, the specified environment variable will be added to the system environment variable. When the variable name is repeated, the existing environment variable will be overridden. When I use source to execute files containing many export commands, one of the export commands adds the default Python version of CONDA to the environment variables of the system, which covers the python version I activated with CONDA before. Therefore, although my CONDA shows that the python version I used is 2.7, the environment variables of the system have been covered by the export command I used later, The default version of Python is 3.8.5.

        I tested again. First add a python version to the environment variable by using export, and then use CONDA activate to activate another version of Python. Using Python on the command line, you will find that the output is the later version of Python. Therefore, you can conclude that the one added after the same variable name in the environment variable will override the existing one.

         Although it’s not a big problem, sometimes it’s this kind of energy-saving twig that keeps you from finding mistakes.