Conda environment activation fails in VS Code - python

When I launch a Python terminal or use Shift+Enter to run code from my Python Files through VS Code on Windows, I get a message:
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.
I get a Python prompt. The code runs as expected. If I exit() that prompt and run "conda activate myenv", the environment activates and I can then run python using the desired environment. However, I can't seem to figure out why it's not activating by default.
I have the MS Python module loaded. Conda is up to date and in my system path. I've installed Conda into cmd and powershell. And the expect "activate" command works if I quit python and type it in. Any ideas what I might be missing?

Please check if you have this setting in your settings.json file,
"python.pythonPath": "<anacondapath>\\envs\\<yourenv>\\python.exe",
This should automatically load the conda environment for you.

Related

Warning "This Python interpreter is in a conda environment, but the environment has not been activated"

I installed miniconda on a Windows machine and whenever I type python in a PowerShell window to start up Python I get the following:
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
I followed the link, but I honestly do not understand what I need to do...
Any tips?
In a command shell:
conda activate
And if this doesn't work yet:
conda init --all

The Conda environment is not activated

I'm learning Python, so I don't know too much about this right now. I just finished installing anaconda, but when I enter python word in the command prompt it give me this error:
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
When I write on cmd -condo activate base- and try to write Python again, the error disappears, but if I don't do that, it continues showing on cmd when writing the python word. Do I need to do something or is it all right?
If the Python interpreter is a part of a Conda environment then you do need to activate the conda environment in order to use it and that is OK.

Python 2.7 Script in Virtual Environment

I am running a Python 2.7 script that has specific dependencies/libraries (contained in a virtual environment) using anaconda prompt. Is there a way to run the script using code in a python 3 .py file in a different environment? Something like a library that allows me to open anaconda prompt in a specific environment (to then run the python 2.7 script). I couldn't seem to find it online. Any pointers would be appreciated.
Well you can select the environment from the drop-down box in the Anaconda Navigator home page if you have your virtual environment in Anaconda itself.
Or you can use
conda activate env-name
If you have your base conda in your terminal as default or else activate using
source ~/.bash_profile
then run
conda activate env-name
Hope this helps.

Why does activating conda environment work in command prompt but not in the terminal in Atom or VS Code (windows)?

I downloaded and installed anaconda, and I am able to create an environment and activate it within the normal windows command prompt. However, when I try to activate it within the terminal in Atom or VS Code (using windows computer), nothing happens
how can I get the development environment to activate within this terminal?
If everything works fine under Command Prompt then you can try using it under VS Code with the following setting:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",

python in conda environment, but cannot activate

I have installed anaconda and create and activated an environment with anaconda prompt.
But when I open python with anaconda, whether inside my anaconda folder or inside the environment folder in it, (or even if I open a python file with spider), it seems it is not using anaconda (according to sys.version).
Indeed python tells me "this python is in a conda environment, but the environment has not been activated".
I have already activated my environment in conda prompt, and I had no error message, so I guess it was succesfful. I have also tried to set my path with in conda prompt: set PATH=C:\Anaconda\envs\py33\Scripts;C:\Anaconda\envs\py33;%PATH% (with my right personal path).
Would you know what is happening?
Thank you
picture of my problem

Categories

Resources