New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate environment not working on windows #1519

Closed
jeremybickerstaffe opened this Issue Aug 12, 2015 · 48 comments

Comments

Projects
None yet
@jeremybickerstaffe

jeremybickerstaffe commented Aug 12, 2015

This morning I installed Anaconda 2.3 with Python 3 on Windows 7 64-bit.
Then I created a Python 2.7 environment in the usual way.
Then I activated it "activate py27" and received a message that it was activated.
Then I ran "python -V" and it reports Python 3.4, not Python 2.7.

Other people have also had this problem, e.g. Shantnu's comment on this page: http://pythonforengineers.com/python-on-windows-causing-you-pain-try-anaconda/

@ccordoba12

This comment has been minimized.

Show comment
Hide comment
@ccordoba12

ccordoba12 Aug 12, 2015

Member

How did you create your Python 2.7 environment?

Member

ccordoba12 commented Aug 12, 2015

How did you create your Python 2.7 environment?

@jeremybickerstaffe

This comment has been minimized.

Show comment
Hide comment
@jeremybickerstaffe

jeremybickerstaffe Aug 12, 2015

I've tried this two ways:

  1. Using the Anaconda launcher - new environment
    creates a minimal python environment with Python itself and not much else.
  2. From the command line:
    conda create -n py27 python=2.7 anaconda

In both cases, typing 'activate py27' returns the message 'Activating environment "py27"...' without errors, but then typing 'python -V' returns 'Python 3.4.3 :: Anaconda 2.3.0 (64-bit).

Is it relevant that I've also tried this on my Mac, yesterday with a new Anaconda installation, and a similar failure to be able to successfully activate a new environment? And in another variation of my testing, I started with Anaconda that had python 2.7 in the root environment, created a new python 3 environment and tried to activate that, and it didn't work either.

In no cases have any errors been raised.

jeremybickerstaffe commented Aug 12, 2015

I've tried this two ways:

  1. Using the Anaconda launcher - new environment
    creates a minimal python environment with Python itself and not much else.
  2. From the command line:
    conda create -n py27 python=2.7 anaconda

In both cases, typing 'activate py27' returns the message 'Activating environment "py27"...' without errors, but then typing 'python -V' returns 'Python 3.4.3 :: Anaconda 2.3.0 (64-bit).

Is it relevant that I've also tried this on my Mac, yesterday with a new Anaconda installation, and a similar failure to be able to successfully activate a new environment? And in another variation of my testing, I started with Anaconda that had python 2.7 in the root environment, created a new python 3 environment and tried to activate that, and it didn't work either.

In no cases have any errors been raised.

@AnneTheAgile

This comment has been minimized.

Show comment
Hide comment
@AnneTheAgile

AnneTheAgile Aug 16, 2015

fyi, windows 8, batch command line, it seems to be working for me.

AnneTheAgile commented Aug 16, 2015

fyi, windows 8, batch command line, it seems to be working for me.

@DancingQuanta

This comment has been minimized.

Show comment
Hide comment
@DancingQuanta

DancingQuanta Aug 29, 2015

What is your output to the command 'echo %PATH%' without quotes before and after activate command?
The activate command should add the environment to your PATH.

DancingQuanta commented Aug 29, 2015

What is your output to the command 'echo %PATH%' without quotes before and after activate command?
The activate command should add the environment to your PATH.

@jeremybickerstaffe

This comment has been minimized.

Show comment
Hide comment
@jeremybickerstaffe

jeremybickerstaffe Aug 30, 2015

I figured it out on Windows: I was using Powershell, which apparently isn't compatible. However, there's an improvement that can be made: on Powershell there's no indication that it won't work or hasn't worked, you get the right messages but it silently fails. Not sure what wasn't working on my Mac but that's ok as well now.

Jeremy


Sent from Mailbox

On Sat, Aug 29, 2015 at 8:53 PM, DancingQuanta notifications@github.com
wrote:

What is your output to the command 'echo %PATH%' without quotes before and after activate command?

Reply to this email directly or view it on GitHub:
#1519 (comment)

jeremybickerstaffe commented Aug 30, 2015

I figured it out on Windows: I was using Powershell, which apparently isn't compatible. However, there's an improvement that can be made: on Powershell there's no indication that it won't work or hasn't worked, you get the right messages but it silently fails. Not sure what wasn't working on my Mac but that's ok as well now.

Jeremy


Sent from Mailbox

On Sat, Aug 29, 2015 at 8:53 PM, DancingQuanta notifications@github.com
wrote:

What is your output to the command 'echo %PATH%' without quotes before and after activate command?

Reply to this email directly or view it on GitHub:
#1519 (comment)

@DancingQuanta

This comment has been minimized.

Show comment
Hide comment
@DancingQuanta

DancingQuanta Aug 31, 2015

I believe that it is possible to change anaconda environment within the PowerShell, I mainly use cygwin so I am using similar technique to get it working.

Every shell have its own set of environmental variables such as PATH, when a shell is started it inherit the system and user environment variables from Windows.

The activate script on Windows only work on old command prompt because the script add the path of a new environment to the old command prompt's environmental variables.
If you tried to execute the activate command on the PowerShell, the script works but it DOES not affect the PowerShell's environmental variables.
So you can't use the new environment in PowerShell however, the solution is to write a PowerShell script that adds the anaconda environment to the PowerShell environmental variables instead.

Here how I 'activate' a new anaconda environment in PowerShell manually:

PS C:\> python -V
Python 3.4.1 :: Anaconda 2.3.0 (64-bit)
PS C:\> $env:Path = "D:\Anaconda3\envs\py27;D:\Anaconda3\envs\py27\Scripts;" + $env:Path
PS C:\> python -V
Python 2.7.10 :: Anaconda 2.2.0 (64-bit)
PS C:\>

What I did is to add the path of the new environment and its Scripts directory to the Path of the PowerShell.
I have not tested this properly but the version of python I am using changed so hopefully this works for you.

To change back to old environment you have to restart powershell to clear its environmental variables.

Hope this make sense for you!

DancingQuanta commented Aug 31, 2015

I believe that it is possible to change anaconda environment within the PowerShell, I mainly use cygwin so I am using similar technique to get it working.

Every shell have its own set of environmental variables such as PATH, when a shell is started it inherit the system and user environment variables from Windows.

The activate script on Windows only work on old command prompt because the script add the path of a new environment to the old command prompt's environmental variables.
If you tried to execute the activate command on the PowerShell, the script works but it DOES not affect the PowerShell's environmental variables.
So you can't use the new environment in PowerShell however, the solution is to write a PowerShell script that adds the anaconda environment to the PowerShell environmental variables instead.

Here how I 'activate' a new anaconda environment in PowerShell manually:

PS C:\> python -V
Python 3.4.1 :: Anaconda 2.3.0 (64-bit)
PS C:\> $env:Path = "D:\Anaconda3\envs\py27;D:\Anaconda3\envs\py27\Scripts;" + $env:Path
PS C:\> python -V
Python 2.7.10 :: Anaconda 2.2.0 (64-bit)
PS C:\>

What I did is to add the path of the new environment and its Scripts directory to the Path of the PowerShell.
I have not tested this properly but the version of python I am using changed so hopefully this works for you.

To change back to old environment you have to restart powershell to clear its environmental variables.

Hope this make sense for you!

@endolith

This comment has been minimized.

Show comment
Hide comment
@endolith

endolith Sep 26, 2015

interestingly, this works from cmd.exe, but not from "Anaconda Command Prompt"

endolith commented Sep 26, 2015

interestingly, this works from cmd.exe, but not from "Anaconda Command Prompt"

@amodig

This comment has been minimized.

Show comment
Hide comment
@amodig

amodig Nov 5, 2015

I can confirm that Anaconda Prompt has problems. After a fresh install, (de)activating worked from "Anaconda2" root environment, but after changing or deactivating environment, (de)activating didn't work anymore. But cmd.exe works.

amodig commented Nov 5, 2015

I can confirm that Anaconda Prompt has problems. After a fresh install, (de)activating worked from "Anaconda2" root environment, but after changing or deactivating environment, (de)activating didn't work anymore. But cmd.exe works.

@David-OConnor

This comment has been minimized.

Show comment
Hide comment
@David-OConnor

David-OConnor Nov 8, 2015

Same issue here. Not working in Ipython QT console, not working in powershell; cmd works.

David-OConnor commented Nov 8, 2015

Same issue here. Not working in Ipython QT console, not working in powershell; cmd works.

@gglanzani

This comment has been minimized.

Show comment
Hide comment
@gglanzani

gglanzani Nov 11, 2015

Same issue here, working only in cmd, not working in Powershell or babun

gglanzani commented Nov 11, 2015

Same issue here, working only in cmd, not working in Powershell or babun

@BjoernBerlin

This comment has been minimized.

Show comment
Hide comment
@BjoernBerlin

BjoernBerlin Dec 3, 2015

I'm not using powershell. I guess I have another issue. My windows account contains a space. This didn't use to be a problem; until recently (two weeks ago it worked...) I could create and activate envs from the command line. Today I got:

<No environment named "flask" exists in C:\Users\xxxx, or is not a valid conda installation directory.>

conda info --envs still reveals my envs, I just cannot reach them anymore. I can still set my env in the Anaconda console...2 years ago there was an issue with this (windows accounts with a space), but that was reported to be settled.

I don't want to change my name and directory. Any ideas?

BjoernBerlin commented Dec 3, 2015

I'm not using powershell. I guess I have another issue. My windows account contains a space. This didn't use to be a problem; until recently (two weeks ago it worked...) I could create and activate envs from the command line. Today I got:

<No environment named "flask" exists in C:\Users\xxxx, or is not a valid conda installation directory.>

conda info --envs still reveals my envs, I just cannot reach them anymore. I can still set my env in the Anaconda console...2 years ago there was an issue with this (windows accounts with a space), but that was reported to be settled.

I don't want to change my name and directory. Any ideas?

@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Dec 3, 2015

Contributor

@BjoernBerlin what is your version of conda-env? The issue would be part of that package currently. Please let us know, and in the meantime, we'll double-check our code there.

Contributor

msarahan commented Dec 3, 2015

@BjoernBerlin what is your version of conda-env? The issue would be part of that package currently. Please let us know, and in the meantime, we'll double-check our code there.

@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Dec 3, 2015

Contributor

See https://github.com/conda/conda-env/blob/develop/bin/activate.bat#L6

I think you may be better if that line reads:

    FOR /F %%i IN ("%~dp0..\envs") DO set "CONDA_ENVS_PATH=%%~fi"

instead of

    FOR /F %%i IN ("%~dp0..\envs") DO set CONDA_ENVS_PATH=%%~fi

Can you try this on your Scripts\activate.bat file and see if it fixes your issue?

Contributor

msarahan commented Dec 3, 2015

See https://github.com/conda/conda-env/blob/develop/bin/activate.bat#L6

I think you may be better if that line reads:

    FOR /F %%i IN ("%~dp0..\envs") DO set "CONDA_ENVS_PATH=%%~fi"

instead of

    FOR /F %%i IN ("%~dp0..\envs") DO set CONDA_ENVS_PATH=%%~fi

Can you try this on your Scripts\activate.bat file and see if it fixes your issue?

@BjoernBerlin

This comment has been minimized.

Show comment
Hide comment
@BjoernBerlin

BjoernBerlin Dec 4, 2015

msarahan, that was quick.
I changed activate.bat, but still can't activate the envs. I guess something is wrong with all the paths, because conda update anaconda or conda update --all won't go through, either:
Could not open ... for writing, no such file or directory

conda info yields:
Current conda install: platform : win-64 conda version : 3.18.7 conda-build version : 1.14.1 python version : 3.4.3.final.0 requests version : 2.8.1 root environment : C:\Users\Administrator Bjoern\Anaconda3 (writable) default environment : C:\Users\Administrator Bjoern\Anaconda3 envs directories : C:\Users\Administrator package cache : C:\Users\Administrator\.pkgs channel URLs : https://repo.continuum.io/pkgs/free/win-64/ https://repo.continuum.io/pkgs/free/noarch/ https://repo.continuum.io/pkgs/pro/win-64/ https://repo.continuum.io/pkgs/pro/noarch/ config file : None is foreign system : False

BjoernBerlin commented Dec 4, 2015

msarahan, that was quick.
I changed activate.bat, but still can't activate the envs. I guess something is wrong with all the paths, because conda update anaconda or conda update --all won't go through, either:
Could not open ... for writing, no such file or directory

conda info yields:
Current conda install: platform : win-64 conda version : 3.18.7 conda-build version : 1.14.1 python version : 3.4.3.final.0 requests version : 2.8.1 root environment : C:\Users\Administrator Bjoern\Anaconda3 (writable) default environment : C:\Users\Administrator Bjoern\Anaconda3 envs directories : C:\Users\Administrator package cache : C:\Users\Administrator\.pkgs channel URLs : https://repo.continuum.io/pkgs/free/win-64/ https://repo.continuum.io/pkgs/free/noarch/ https://repo.continuum.io/pkgs/pro/win-64/ https://repo.continuum.io/pkgs/pro/noarch/ config file : None is foreign system : False

@gglanzani

This comment has been minimized.

Show comment
Hide comment
@gglanzani

gglanzani commented Dec 4, 2015

Just a side note: https://pypi.python.org/pypi/virtualenvwrapper-win has the same problem.

@navneethc

This comment has been minimized.

Show comment
Hide comment
@navneethc

navneethc Jan 23, 2016

Yes, I'm also one of those seeking a solution to this problem for quite a while (Win7/64-bit). I can confirm that cmd works, but unfortunately pressing Ctrl+D does exit the Python shell, unlike the Python interpreter called from the Anaconda shell.

navneethc commented Jan 23, 2016

Yes, I'm also one of those seeking a solution to this problem for quite a while (Win7/64-bit). I can confirm that cmd works, but unfortunately pressing Ctrl+D does exit the Python shell, unlike the Python interpreter called from the Anaconda shell.

@drcoll

This comment has been minimized.

Show comment
Hide comment
@drcoll

drcoll Jan 26, 2016

Is there a fix on the way for this?

drcoll commented Jan 26, 2016

Is there a fix on the way for this?

@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Jan 26, 2016

Contributor

This should actually be long-fixed. Sorry for not posting here.

conda update conda-env

Should get you a version that handles spaces much better.

Contributor

msarahan commented Jan 26, 2016

This should actually be long-fixed. Sorry for not posting here.

conda update conda-env

Should get you a version that handles spaces much better.

@drcoll

This comment has been minimized.

Show comment
Hide comment
@drcoll

drcoll Jan 26, 2016

Hm, I must be experiencing a separate issue. The "activate {envname}" command is not found, and I attempt to use "activate.bat {envname}" and it says Activating environment "..." but upon using "conda info --env" it appears to have been unsuccessful as the environment is still set to root.

drcoll commented Jan 26, 2016

Hm, I must be experiencing a separate issue. The "activate {envname}" command is not found, and I attempt to use "activate.bat {envname}" and it says Activating environment "..." but upon using "conda info --env" it appears to have been unsuccessful as the environment is still set to root.

@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Jan 26, 2016

Contributor

You are probably trying to use powershell. Only cmd.exe is supported right now. We hope to change that soon.

Contributor

msarahan commented Jan 26, 2016

You are probably trying to use powershell. Only cmd.exe is supported right now. We hope to change that soon.

@drcoll

This comment has been minimized.

Show comment
Hide comment
@drcoll

drcoll Jan 27, 2016

Ah.. that was it. I was using Cygwin. Thank you.

drcoll commented Jan 27, 2016

Ah.. that was it. I was using Cygwin. Thank you.

@navneethc

This comment has been minimized.

Show comment
Hide comment
@navneethc

navneethc Jan 27, 2016

msarahan,
I seem to have the latest version of conda-env.

>conda update conda-env
Fetching package metadata: ....
# All requested packages already installed.
# packages in environment at C:\Users\chandrav\AppData\Local\Continuum\Anaconda:
#
conda-env                 2.4.5                    py27_0

navneethc commented Jan 27, 2016

msarahan,
I seem to have the latest version of conda-env.

>conda update conda-env
Fetching package metadata: ....
# All requested packages already installed.
# packages in environment at C:\Users\chandrav\AppData\Local\Continuum\Anaconda:
#
conda-env                 2.4.5                    py27_0
@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Jan 27, 2016

Contributor

@navneethc Ctrl-d behavior changed from python 2 to python 3. That's an
upstream change that honestly annoys me also. However, it is not related
to this issue. Please open a new issue if you feel it necessary.

On Wed, Jan 27, 2016, 00:25 navneethc notifications@github.com wrote:

msarahan,
I seem to have the latest version conda-env.

conda update conda-env
Fetching package metadata: ....

All requested packages already installed.

packages in environment at C:\Users\chandrav\AppData\Local\Continuum\Anaconda:

conda-env 2.4.5 py27_0


Reply to this email directly or view it on GitHub
#1519 (comment).

Contributor

msarahan commented Jan 27, 2016

@navneethc Ctrl-d behavior changed from python 2 to python 3. That's an
upstream change that honestly annoys me also. However, it is not related
to this issue. Please open a new issue if you feel it necessary.

On Wed, Jan 27, 2016, 00:25 navneethc notifications@github.com wrote:

msarahan,
I seem to have the latest version conda-env.

conda update conda-env
Fetching package metadata: ....

All requested packages already installed.

packages in environment at C:\Users\chandrav\AppData\Local\Continuum\Anaconda:

conda-env 2.4.5 py27_0


Reply to this email directly or view it on GitHub
#1519 (comment).

@navneethc

This comment has been minimized.

Show comment
Hide comment
@navneethc

navneethc Jan 27, 2016

msarahan, Thanks for the reply, but my issue is still that I'm not able to actually activate and use the other environment from the Anaconda prompt, despite using the latest version of conda-env. I should have made it clear that the CTRL+D issue was just an aside. :-)

C:\Users\chandrav\AppData\Local\Continuum\Anaconda>conda update conda-env
Fetching package metadata: ....
# All requested packages already installed.
# packages in environment at C:\Users\chandrav\AppData\Local\Continuum\Anaconda:
#
conda-env                 2.4.5                    py27_0

C:\Users\chandrav\AppData\Local\Continuum\Anaconda>conda info --envs
# conda environments:
#
py3env                   C:\Users\chandrav\AppData\Local\Continuum\Anaconda\envs\py3env
root                  *  C:\Users\chandrav\AppData\Local\Continuum\Anaconda


C:\Users\chandrav\AppData\Local\Continuum\Anaconda>activate py3env
Deactivating environment "C:\Users\chandrav\AppData\Local\Continuum\Anaconda"...
Activating environment "C:\Users\chandrav\AppData\Local\Continuum\Anaconda\envs\py3env"...

[py3env] C:\Users\chandrav\AppData\Local\Continuum\Anaconda>python
Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Dec  7 2015, 14:10:42) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>>

[py3env] C:\Users\chandrav\AppData\Local\Continuum\Anaconda>

navneethc commented Jan 27, 2016

msarahan, Thanks for the reply, but my issue is still that I'm not able to actually activate and use the other environment from the Anaconda prompt, despite using the latest version of conda-env. I should have made it clear that the CTRL+D issue was just an aside. :-)

C:\Users\chandrav\AppData\Local\Continuum\Anaconda>conda update conda-env
Fetching package metadata: ....
# All requested packages already installed.
# packages in environment at C:\Users\chandrav\AppData\Local\Continuum\Anaconda:
#
conda-env                 2.4.5                    py27_0

C:\Users\chandrav\AppData\Local\Continuum\Anaconda>conda info --envs
# conda environments:
#
py3env                   C:\Users\chandrav\AppData\Local\Continuum\Anaconda\envs\py3env
root                  *  C:\Users\chandrav\AppData\Local\Continuum\Anaconda


C:\Users\chandrav\AppData\Local\Continuum\Anaconda>activate py3env
Deactivating environment "C:\Users\chandrav\AppData\Local\Continuum\Anaconda"...
Activating environment "C:\Users\chandrav\AppData\Local\Continuum\Anaconda\envs\py3env"...

[py3env] C:\Users\chandrav\AppData\Local\Continuum\Anaconda>python
Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Dec  7 2015, 14:10:42) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>>

[py3env] C:\Users\chandrav\AppData\Local\Continuum\Anaconda>
@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Jan 27, 2016

Contributor

So this is a confusion that I've bumped into. If you run activate.bat while in the root of your root environment, it doesn't drop you into a new folder. You're still in the root of your root environment. Guess what else is in that folder? Python.exe - whatever version your root installation is. Thus, it appears that you haven't activated the environment, but the real issue is that it's finding the local python.exe before it even goes looking for stuff on PATH.

CD into a different folder, and you should see the correct Python.

Contributor

msarahan commented Jan 27, 2016

So this is a confusion that I've bumped into. If you run activate.bat while in the root of your root environment, it doesn't drop you into a new folder. You're still in the root of your root environment. Guess what else is in that folder? Python.exe - whatever version your root installation is. Thus, it appears that you haven't activated the environment, but the real issue is that it's finding the local python.exe before it even goes looking for stuff on PATH.

CD into a different folder, and you should see the correct Python.

@navneethc

This comment has been minimized.

Show comment
Hide comment
@navneethc

navneethc Jan 27, 2016

Yes, cd-ing into the env folder is what I do now, but that sort of defeats the purpose of the activate command. :-)

Some of the things that are part of 'activation' does happen: e.g., PATH is prefixed with the environment path, the prompt is prefixed with the env name etc. But yes, it still calls the local/root version (in my case, 2.7).

navneethc commented Jan 27, 2016

Yes, cd-ing into the env folder is what I do now, but that sort of defeats the purpose of the activate command. :-)

Some of the things that are part of 'activation' does happen: e.g., PATH is prefixed with the environment path, the prompt is prefixed with the env name etc. But yes, it still calls the local/root version (in my case, 2.7).

@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Jan 27, 2016

Contributor

No, you don't need to cd into the env folder - you just need to NOT be in
the root install folder. You can be absolutely anywhere else, and it
should work.

On Wed, Jan 27, 2016 at 8:55 AM navneethc notifications@github.com wrote:

Yes, cd-ing into the env folder is what I do now, but that sort of defeats
the purpose of the activate command. :-)

Some of the things that are part of 'activation' does happen: e.g., PATH
is prefixed with the environment path, the prompt is prefixed with the env
name etc. But yes, it still calls the local/root version (in my case, 2.7).


Reply to this email directly or view it on GitHub
#1519 (comment).

Contributor

msarahan commented Jan 27, 2016

No, you don't need to cd into the env folder - you just need to NOT be in
the root install folder. You can be absolutely anywhere else, and it
should work.

On Wed, Jan 27, 2016 at 8:55 AM navneethc notifications@github.com wrote:

Yes, cd-ing into the env folder is what I do now, but that sort of defeats
the purpose of the activate command. :-)

Some of the things that are part of 'activation' does happen: e.g., PATH
is prefixed with the environment path, the prompt is prefixed with the env
name etc. But yes, it still calls the local/root version (in my case, 2.7).


Reply to this email directly or view it on GitHub
#1519 (comment).

@navneethc

This comment has been minimized.

Show comment
Hide comment
@navneethc

navneethc Jan 27, 2016

Yes, that works.

navneethc commented Jan 27, 2016

Yes, that works.

@Ron024

This comment has been minimized.

Show comment
Hide comment
@Ron024

Ron024 Feb 18, 2016

I seem to be having the same issue. I am testing out miniconda and I do not want to mess with my current python path settings so I am working out of the base directory. When I try to switch environments I get the following error.

c:\Users\Username\Portable Apps\Miniconda2\Scripts>activate snowflakes
Apps\Portable was unexpected at this time.

Even moving out of the directory I get the same error.

c:\Windows>"c:\Users\Username\Portable Apps\Miniconda2\Scripts\activate.bat" snowflakes
Apps\Portable was unexpected at this time.

Everyhting is up to date:

c:\Users\Username\Portable Apps\Miniconda2\Scripts>conda --version
conda 3.19.1

c:\Users\Username\Portable Apps\Miniconda2\Scripts>conda update conda-env
Fetching package metadata: ....
# All requested packages already installed.
# packages in environment at c:\Users\Username\Portable Apps\Miniconda2:
#
conda-env                 2.4.5                    py27_0

Ron024 commented Feb 18, 2016

I seem to be having the same issue. I am testing out miniconda and I do not want to mess with my current python path settings so I am working out of the base directory. When I try to switch environments I get the following error.

c:\Users\Username\Portable Apps\Miniconda2\Scripts>activate snowflakes
Apps\Portable was unexpected at this time.

Even moving out of the directory I get the same error.

c:\Windows>"c:\Users\Username\Portable Apps\Miniconda2\Scripts\activate.bat" snowflakes
Apps\Portable was unexpected at this time.

Everyhting is up to date:

c:\Users\Username\Portable Apps\Miniconda2\Scripts>conda --version
conda 3.19.1

c:\Users\Username\Portable Apps\Miniconda2\Scripts>conda update conda-env
Fetching package metadata: ....
# All requested packages already installed.
# packages in environment at c:\Users\Username\Portable Apps\Miniconda2:
#
conda-env                 2.4.5                    py27_0
@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Feb 18, 2016

Contributor

@Ron024 this is a new one - somehow the script is reversing "Portable Apps". I have tested it fairly thoroughly with spaces in paths, and haven't seen something like this. One thing you can do to help us debug is to edit the activate.bat script at the top, and replace

@echo off

with

@echo on

That should show us exactly where in the script this problem is showing up.

Contributor

msarahan commented Feb 18, 2016

@Ron024 this is a new one - somehow the script is reversing "Portable Apps". I have tested it fairly thoroughly with spaces in paths, and haven't seen something like this. One thing you can do to help us debug is to edit the activate.bat script at the top, and replace

@echo off

with

@echo on

That should show us exactly where in the script this problem is showing up.

@Ron024

This comment has been minimized.

Show comment
Hide comment
@Ron024

Ron024 commented Feb 21, 2016

Here is the @echo on
error.txt

@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Feb 21, 2016

Contributor

@Ron024 there are a couple of things strange in there:

  1. I haven't seen this script before with shortened path styles (Minic~1). I think this should work, but I haven't explicitly tested it. What OS are you on?
  2. You have several entries in your PATH with quotes. That's very bad. That breaks any batch file's ability to interpret your PATH as a single string. These are unnecessary, and also just bad. Please edit your PATH variable to remove all quotes. Spaces are OK in PATH, but quotes are not. See http://superuser.com/a/452357/184799 Note that this differs from the command prompt itself, where you should quote paths with spaces.
Contributor

msarahan commented Feb 21, 2016

@Ron024 there are a couple of things strange in there:

  1. I haven't seen this script before with shortened path styles (Minic~1). I think this should work, but I haven't explicitly tested it. What OS are you on?
  2. You have several entries in your PATH with quotes. That's very bad. That breaks any batch file's ability to interpret your PATH as a single string. These are unnecessary, and also just bad. Please edit your PATH variable to remove all quotes. Spaces are OK in PATH, but quotes are not. See http://superuser.com/a/452357/184799 Note that this differs from the command prompt itself, where you should quote paths with spaces.
@Ron024

This comment has been minimized.

Show comment
Hide comment
@Ron024

Ron024 Feb 22, 2016

I am on Win 7 x32. I did not know that quotes weren't necessary in the path. It makes sense for the batch file. I removed them and it worked correctly, paths show up as full length.

Ron024 commented Feb 22, 2016

I am on Win 7 x32. I did not know that quotes weren't necessary in the path. It makes sense for the batch file. I removed them and it worked correctly, paths show up as full length.

@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Feb 22, 2016

Contributor

So the activate script is working now?

Contributor

msarahan commented Feb 22, 2016

So the activate script is working now?

@Ron024

This comment has been minimized.

Show comment
Hide comment
@Ron024

Ron024 Feb 22, 2016

Yes, it is working as it should.

Ron024 commented Feb 22, 2016

Yes, it is working as it should.

@msarahan

This comment has been minimized.

Show comment
Hide comment
@msarahan

msarahan Feb 22, 2016

Contributor

Thanks. Closing this issue. Anyone in the future, please open a new one.

Contributor

msarahan commented Feb 22, 2016

Thanks. Closing this issue. Anyone in the future, please open a new one.

@msarahan msarahan closed this Feb 22, 2016

@PhanDuc

This comment has been minimized.

Show comment
Hide comment
@PhanDuc

PhanDuc Mar 2, 2017

Hi
I also have an error in Windows 10 64 bit :

C:\WINDOWS\system32>conda info --envs
# conda environments:
#
tensorflow-gpu           C:\Program Files\Anaconda3\envs\tensorflow-gpu
root                  *  C:\Program Files\Anaconda3
C:\WINDOWS\system32>activate tensorflow-gpu
C:\WINDOWS\system32>pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.0.0-cp35-cp35m-win_x86_64.whl
tensorflow_gpu-1.0.0-cp35-cp35m-win_x86_64.whl is not a supported wheel on this platform.

I couldn't switch to my environment tensorflow-gpu
How to fix my problem ?
Many thanks

PhanDuc commented Mar 2, 2017

Hi
I also have an error in Windows 10 64 bit :

C:\WINDOWS\system32>conda info --envs
# conda environments:
#
tensorflow-gpu           C:\Program Files\Anaconda3\envs\tensorflow-gpu
root                  *  C:\Program Files\Anaconda3
C:\WINDOWS\system32>activate tensorflow-gpu
C:\WINDOWS\system32>pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.0.0-cp35-cp35m-win_x86_64.whl
tensorflow_gpu-1.0.0-cp35-cp35m-win_x86_64.whl is not a supported wheel on this platform.

I couldn't switch to my environment tensorflow-gpu
How to fix my problem ?
Many thanks

@masepi

This comment has been minimized.

Show comment
Hide comment
@masepi

masepi Mar 21, 2017

Can't change environment using activate

conda --version
4.13.4
Win10 Pro x64

Any ideas?

masepi commented Mar 21, 2017

Can't change environment using activate

conda --version
4.13.4
Win10 Pro x64

Any ideas?

@mingwandroid

This comment has been minimized.

Show comment
Hide comment
@mingwandroid

mingwandroid Mar 21, 2017

Contributor

@PhanDuc, please do not install Anaconda into a location containing spaces.
@masepi, you need to give detailed output for what happens (i.e. what is printed out) when you try to change environment using activate.

This issue is probably not related to you are running into though.

Contributor

mingwandroid commented Mar 21, 2017

@PhanDuc, please do not install Anaconda into a location containing spaces.
@masepi, you need to give detailed output for what happens (i.e. what is printed out) when you try to change environment using activate.

This issue is probably not related to you are running into though.

@masepi

This comment has been minimized.

Show comment
Hide comment
@masepi

masepi Mar 21, 2017

Problem with powershell!
With cmd all is fine.

masepi commented Mar 21, 2017

Problem with powershell!
With cmd all is fine.

@mingwandroid

This comment has been minimized.

Show comment
Hide comment
@mingwandroid

mingwandroid Mar 21, 2017

Contributor

OK, we do not support PowerShell at present.

Contributor

mingwandroid commented Mar 21, 2017

OK, we do not support PowerShell at present.

@borgeslt

This comment has been minimized.

Show comment
Hide comment
@borgeslt

borgeslt Mar 24, 2017

Hi folks,

I just execute the same command of the "Anaconda prompt", copied from the shortcut, in the PowerShell and it worked for me:

image

Hope help you too!

borgeslt commented Mar 24, 2017

Hi folks,

I just execute the same command of the "Anaconda prompt", copied from the shortcut, in the PowerShell and it worked for me:

image

Hope help you too!

@eliasah

This comment has been minimized.

Show comment
Hide comment
@eliasah

eliasah Mar 24, 2017

The solution proposed by @borgeslt is a good workaround to use it from PowerShell. Nevertheless at least it can (should) be documented somewhere.

eliasah commented Mar 24, 2017

The solution proposed by @borgeslt is a good workaround to use it from PowerShell. Nevertheless at least it can (should) be documented somewhere.

@ptarwireyi

This comment has been minimized.

Show comment
Hide comment
@ptarwireyi

ptarwireyi May 9, 2017

In windows 10, click on the start menu and navigate to Anaconda, Click on Anaconda Prompt.... All commands should work without issues.

(C:\ProgramData\Anaconda3) C:\Users\pt>conda info --envs

conda environments:

27 C:\Users\pt\AppData\Local\conda\conda\envs\27
py27 C:\Users\pt\AppData\Local\conda\conda\envs\py27
spyder C:\Users\pt\AppData\Local\conda\conda\envs\spyder
twoseven C:\Users\pt\AppData\Local\conda\conda\envs\twoseven
root * C:\ProgramData\Anaconda3

(C:\ProgramData\Anaconda3) C:\Users\pt>activate py27

(py27) C:\Users\tarwireyip>conda info --envs

conda environments:

27 C:\Users\pt\AppData\Local\conda\conda\envs\27
py27 * C:\Users\pt\AppData\Local\conda\conda\envs\py27
spyder C:\Users\pt\AppData\Local\conda\conda\envs\spyder
twoseven C:\Users\pt\AppData\Local\conda\conda\envs\twoseven
root C:\ProgramData\Anaconda3

ptarwireyi commented May 9, 2017

In windows 10, click on the start menu and navigate to Anaconda, Click on Anaconda Prompt.... All commands should work without issues.

(C:\ProgramData\Anaconda3) C:\Users\pt>conda info --envs

conda environments:

27 C:\Users\pt\AppData\Local\conda\conda\envs\27
py27 C:\Users\pt\AppData\Local\conda\conda\envs\py27
spyder C:\Users\pt\AppData\Local\conda\conda\envs\spyder
twoseven C:\Users\pt\AppData\Local\conda\conda\envs\twoseven
root * C:\ProgramData\Anaconda3

(C:\ProgramData\Anaconda3) C:\Users\pt>activate py27

(py27) C:\Users\tarwireyip>conda info --envs

conda environments:

27 C:\Users\pt\AppData\Local\conda\conda\envs\27
py27 * C:\Users\pt\AppData\Local\conda\conda\envs\py27
spyder C:\Users\pt\AppData\Local\conda\conda\envs\spyder
twoseven C:\Users\pt\AppData\Local\conda\conda\envs\twoseven
root C:\ProgramData\Anaconda3

@Jaykul

This comment has been minimized.

Show comment
Hide comment
@Jaykul

Jaykul Jul 10, 2017

If you want a workaround for doing it from PowerShell the Quick-n-Dirty way, instead of rewriting the cmd batch file as a PowerShell ps1 script (which would be the right solution), you can just run the current cmd script, and capture the environment changes and set them in PowerShell.

Here's an example of PowerShell script which will run a cmd batch file with the same name from the same folder, and import any changes it makes to the environment:

Push-Location $PSScriptRoot
$TempEnv = [IO.Path]::GetTempFileName()
# use the path without the extension to allow .bat or .cmd
$command = [IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand)
$param = $args -join " "

cmd.exe /c "$command $param && set > $TempEnv"
foreach($line in Get-Content $TempEnv){
    $name,$value = $line -split "=",2
    Set-Content Env:$name $value
}
Pop-Location

Jaykul commented Jul 10, 2017

If you want a workaround for doing it from PowerShell the Quick-n-Dirty way, instead of rewriting the cmd batch file as a PowerShell ps1 script (which would be the right solution), you can just run the current cmd script, and capture the environment changes and set them in PowerShell.

Here's an example of PowerShell script which will run a cmd batch file with the same name from the same folder, and import any changes it makes to the environment:

Push-Location $PSScriptRoot
$TempEnv = [IO.Path]::GetTempFileName()
# use the path without the extension to allow .bat or .cmd
$command = [IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand)
$param = $args -join " "

cmd.exe /c "$command $param && set > $TempEnv"
foreach($line in Get-Content $TempEnv){
    $name,$value = $line -split "=",2
    Set-Content Env:$name $value
}
Pop-Location
@clived2

This comment has been minimized.

Show comment
Hide comment
@clived2

clived2 Sep 21, 2017

I know this is an old thread, but I have more experience with Anaconda3 on Ubuntu, this is my first try on Windows 10. Can't seem to be able to get to the Anaconda Prompt screen ,I end up with the following:
The system cannot find the path specified. Seems I am not the only one with this issue. I can't even check
"conda info --envs". I would hope that there is a fix for this.

Any assistance would be appreciated

Clive

clived2 commented Sep 21, 2017

I know this is an old thread, but I have more experience with Anaconda3 on Ubuntu, this is my first try on Windows 10. Can't seem to be able to get to the Anaconda Prompt screen ,I end up with the following:
The system cannot find the path specified. Seems I am not the only one with this issue. I can't even check
"conda info --envs". I would hope that there is a fix for this.

Any assistance would be appreciated

Clive

@fastlater

This comment has been minimized.

Show comment
Hide comment
@fastlater

fastlater Nov 7, 2017

@clived2 I am having the same problem. I install it and everything is ok. When I want to open the Anaconda prompt, it say The system cannot find the path specified.
I was looking at the bat files and I realized that these files are edited as below:
@echo off
call "C:\Anaconda2\Scripts\conda" %*

Why do bat files are reedited by the computer? @msarahan

fastlater commented Nov 7, 2017

@clived2 I am having the same problem. I install it and everything is ok. When I want to open the Anaconda prompt, it say The system cannot find the path specified.
I was looking at the bat files and I realized that these files are edited as below:
@echo off
call "C:\Anaconda2\Scripts\conda" %*

Why do bat files are reedited by the computer? @msarahan

@mbargull mbargull added the tag-shell label Mar 13, 2018

@Vedant1202

This comment has been minimized.

Show comment
Hide comment
@Vedant1202

Vedant1202 Aug 16, 2018

For windows, you can try "conda activate ". Worked for conda 5.2

Vedant1202 commented Aug 16, 2018

For windows, you can try "conda activate ". Worked for conda 5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment