11

I created a Windows (10) Python virtual environment (env3.7.3). When I open a cmd window activated in the virtual env, I get the following warning message when starting Python in the virtual env:

(env3.7.3) C:\Users\redex\OneDrive\Documents\Education\Machine Learning-Ng Python\Exercise7>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

This warning has been posted before in a different context but it did not address my question. This warning appears only in the python virtual env, not the base conda env. This seems like a windows or anaconda environment variable issue but I don't know enough to know! Anaconda was recently upgraded and it seemed fine before, so there may be a bug or setting issue.

Any guidance or expertise on this matter would be much appreciated.

Bill
  • 473
  • 1
  • 5
  • 12
  • Did you ever find a solution for this? I myself use conda alongside venv for different purpose (conda is for data sciency stuffy, venv is for backend stuff). It's not breaking anything because if I call `sys.executable` within my venv it points to the proper one, but it's annoying to have this warning when it's not supposed to happen. – wtfzambo Apr 19 '21 at 15:22

5 Answers5

6

The error message tells you that the Python interpreter from the conda environment was found, but that conda activate <envname> has not been called. Did you put the bin/ directory of the conda env into the Windows search path? That would be wrong.

You're talking about virtual envs. But Python virtual environments are something else than conda environments. Maybe you mixed up the two concepts?

The Python interpreter from the conda base environment does not complain about missing activation, because it's called by some of the conda subcommands and can work without an activated environment. Nevertheless, you should call conda activate base when working with that conda environment, too.

Roland Weber
  • 2,516
  • 8
  • 19
  • Thanks for the reply. My intention is to create a Python virtual env, not a conda environment. The reason is related to a problem VS Code has with conda when invoking the debugger (see https://stackoverflow.com/questions/56475068/why-doesnt-vscode-activate-conda-before-starting-the-debugger/56676210#56676210) By creating a local python virtual environment, the debugger works properly. – Bill Jun 20 '19 at 17:13
  • 2
    @Bill If you want to work with Python virtual environments, then don't use `conda` at all. The two don't mix. – Roland Weber Jun 21 '19 at 08:38
1

Where myenv is "your env name",

Try this:

conda activate myenv

conda install pip

This should solve the issue.

SherylHohman
  • 12,507
  • 16
  • 70
  • 78
  • where should I "Try this"? In the Windows cmd, `conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + conda activate myenv` – Yu Xiang Feb 09 '21 at 13:47
0

You have to activate your conda environment after activating your env of Flask. So that you will have two virtual environments as shown here :
$(virtualenv) (env) C:\Users\Public\Projects\FlaskInt>python

0

i met the similar problem,

Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information. Failed calling sys.interactivehook Traceback (most recent call last): File "D:\anaconda\content\lib\site.py", line 439, in register_readline readline.read_history_file(history) File "D:\anaconda\content\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file self.mode._history.read_history_file(filename) File "D:\anaconda\content\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file for line in open(filename, 'r'): UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 1985: illegal multibyte sequence

but i solved the problem by replacing "r" to "rb" in line82. Hope to help you!

-4

Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment please see https://conda.io/activation

  • Please use the answer section for answers only. Please take a moment to read how to write a good [answer](https://stackoverflow.com/help/how-to-answer) – Joe Ferndz Aug 25 '20 at 03:36