Also someone suggested http://stackoverflow.com/questions/3667238/how-can-i-get-the-file-system-location-of-a-powershell-script/3667376#3667376 helps.
Honestly just adding those scripts to the distribution seems to work flawlessly on win7-64bit. Would you like a PR for this?
Sure, but see also https://github.com/conda/conda/pull/913
Ahh, seems like that deals with it all much more nicely. Thanks for the ref.
Will #913 work in Powershell? If not, would it be worth just adding the ps scripts to the distribution?
Is there anything bad about just including ps scripts while you figure out #913 ? I thought conda was supposed to be advertised as more featureful than virtualenv :P
Just to chime in, I also wasted about an hour of time figuring out why my environments weren't activating.
Anaconda envs are advertised as full-featured replacements for venv, so I would expect Powershell support.
If @LiquidMantis or anyone else wants to submit the ps scripts that @rossant mentioned, I'll merge them. It would be nice to not include another license file with Conda. I the meantime, we are reviewing #913 and its newer derivatives and hope to merge it soon.
I'm fine with them being added, and was going to submit a PR now, but it looks like conda has been reworked and the old bat files have been removed anyway so I'm not sure how to proceed.
Things are in a little bit of flux right now. The activate scripts were moved out of conda, into conda-env. This has unfortunately made the activate scripts harder to test, since they effectively depend on two packages. We will be discussing this after the Anaconda 2.4.1 release, and hopefully coming up with a better arrangement. If you put a PR in against conda-env, we'll be happy to consider it, and we'll take care of any moves necessary thereafter.
@msarahan It looks like the Anaconda 2.5 release is out now. Has there been any progress on this? It would greatly improve the Windows UX if this could be fixed. :pray:
@Liquidmantis Seems like the old bat files have been added back. I just tested your scripts from pscondaenvs and they work with conda 4.0.5.
@msarahan would you still accept the pr if @Liquidmantis or anyone else submits them?
Sorry for the delay here. Absolutely.
Before they are accepted, they need to pass the test_activate.py tests. I added a bit of scaffolding for powershell, but didn't want to bloat #1727 any further. Please see this comment for how to run the tests with the new shell (modify test_activate.py, but also pass a command-line argument): https://github.com/conda/conda/pull/1727#issuecomment-191240161
Ping me if you are working on this and need help.
@msarahan just took a look at this today to get it added. Might take me a bit to implement the Powershell test. Just noticed that the section on it is just an exception :person_frowning:
@vmuriart go ahead with a PR whenever, even if tests are not passing. I'll be happy to help you flesh out the framework.
+1, encountering this issue on windows 10.
+1 again, just ran into this again trying to do Py3 testing.
Addressed with #3175 and #3960
Is there any progress on this? just tried https://github.com/Liquidmantis/PSCondaEnvs, but they break
and executing activate.bat within powershell just hangs forever
Same here - I'm very confused about the lack of working PowerShell support.
+1 please support power shell.
+1 Would be nice to have Power Shell support!
+1 Would be great to be able to activate environments in Power Shell on Windows 10
In case anyone is interested, I've written my own little hacky version of the activation script as a Powershell function, by going through the actions the real one performs for CMD.
I'm not sure if it's a 100% perfect, but it seems to be working fine for me.
https://gist.github.com/arvindch/409802ab2f6c4b5aa48a36078e39587e
+1: I'd love to see this
this would seem worthwhile.
+1 Power Shell support
This should be no more than writing an activate function that's aware of powershell's environment variables. re @arvindch
+1
@jmagosta - Yep, my PS function modifies the path and adds the required env variables for conda to work.
It is a tiny bit more. Packages can have additional scripts in the
activate.d folders. Also, you should obtain new PATH entries from conda,
not from imitation of what conda does internally. Other attempts have done
the latter, and gotten out of sync and broken.
On Mar 4, 2017 10:08 AM, "Arvind Chembarpu" notifications@github.com
wrote:
@jmagosta https://github.com/jmagosta - Yep, my PS function modifies
the path and adds the required env variables for conda to work.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/conda/conda/issues/626#issuecomment-284161016, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AACV-Sq1CFtef7kuyuHXdFLUc6ndEbkXks5riYyWgaJpZM4Btxzz
.
@msarahan Definitely, I agree 100%. I am only using this hacky script until Anaconda adds official support, which is slated for v4.4.0.
A quick workaround if you're directly using powershell is to type:
- cmd into powershell to get internally into Command Prompt
- activate EnvName
- powershell to get back
@oblongsquirrel good idea! but to type powershell does not means "go back", since it will create a new process and use more system resources.
While you are technically correct, in the grand scheme of things, those extra system resources shouldn't matter.
@conke Thanks, I'll keep that in mind!
@mingwandroid Oh maybe I won't have to keep it in mind.
@asmeurer Thank you.
I also encountered the same problem. My PC OS is Win10,
activate.ps1 and deactivate.ps1 scripts, and put them in the conda/Scripts PATH, ExecutionPolicy to RemoteSigned activate to change the enviroment in conda.It's not exactly solved, since these scripts aren't integrated into the anaconda package. Having to download them manually and changing execution policy may be fine work-arounds, but I wouldn't consider this fixed until the default distro works with Powershell.
I'd send another PR, but I don't actually understand what is wrong with #3960. Do you have any info why that hasn't been merged @msarahan?
@JeremiahZhang Where are the activate and deactivate scripts located?
@MFry Please see the description in https://github.com/Liquidmantis/PSCondaEnvs.
@masaeedu, @kalefranz is the one to ping on this. I don't know where this is on his timeline.
Shouldn't be too far off now that we have #5044 in.
Hi expert,
I made a quick dirty hack of this problem. The PowerShell script only calls batch file to capture environment variables.
Are there any opinions?
If this seems to be okay, I will create a PR.
https://gist.github.com/takekazuomi/4242137ee3d31c5e42e741dabbcf5e31
I source a file with the Invoke-CmdScript function as described here, and then some wrapper functions like this:
$condaRoot = "$Env:USERPROFILE\Anaconda3"
function Conda-Activate([string]$condaEnv) {Invoke-CmdScript $condaRoot\Scripts\activate.bat $condaEnv}
function Conda-Deactivate {Invoke-CmdScript $condaRoot\Scripts\deactivate.bat}
Works well for me.
Is there a plan for PS to support activate out of the box?
Yes. That's why this issue is still open.
On May 26, 2017, at 3:59 AM, Henry Tanner notifications@github.com wrote:
Is there a plan for PS to support activate out of the box?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
The down and dirty:
1) Check to see if activate works in cmd.exe.
2) If doesn't work or not acceptable--as @TurboTim shows:
Powershell needs the path to each env (anaconda3envssomeenvpy33.exe. Laborious! :p
If you don't mind polluting your powershell a little, you can create a profile script which is run every time you open powershell. The below will add the functions Invoke-CmdScript, Conda-Activate, Conda-Deactivate to your powershell. See Tim's link above for why.
PS C:\> New-Item -Path $profile -ItemType File -Force
This creates a script at:
PS C:\> echo $profile
...something like C:\Users\yourUser\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Edit that script.
PS C:\> explorer $profile
Add this code, save, and reopen powershell (or . $profile ) :
function Invoke-CmdScript {
param(
[String] $scriptName
)
$cmdLine = """$scriptName"" $args & set"
& $Env:SystemRoot\system32\cmd.exe /c $cmdLine |
Select-String '^([^=]*)=(.*)$' | ForEach-Object {
$varName = $_.Matches[0].Groups[1].Value
$varValue = $_.Matches[0].Groups[2].Value
Set-Item Env:$varName $varValue
}
}
$condaRoot = "$Env:USERPROFILE\Anaconda3"
function Conda-Activate([string]$condaEnv) {Invoke-CmdScript $condaRoot\Scripts\activate.bat $condaEnv}
function Conda-Deactivate {Invoke-CmdScript $condaRoot\Scripts\deactivate.bat}
Usage:
C:\> Conda-Activate TFTheano
C:\> Conda-Activate root
C:\> conda info --envs
Disclaimers: Deactivate, as written, didn't do the job for me, thus I just use Conda-Activate to move around. Also, I don't suspect there are security cautions with adding Invoke-Cmd to profile, so please chime in if 2 cents.
None of the solutions worked for me so I wrote my own activate.ps/deactivate.ps1 scripts:
https://github.com/BCSharp/PSCondaEnvs
Works on Windows/macOS/Linux, works for additional user environments in ~/.conda/envs.
I've been building on BCSharp's excellent work at my own repo (currently on PR).
Just do:
conda install -n root -c pscondaenvs pscondaenvs
You need Conda 4.1 or above (check with conda info conda) - otherwise please install the latest version.
Behavior is exactly like CMD - use activate or deactivate appropriately. It's completely backwards compatible and will also launch both .ps1 and .bat activate.d/deactivate.d scripts.
Hi @darkdreamingdan , thanks for the work.
I ran conda install -n root -c pscondaenvs pscondaenvs in the powershell and got a success message by the end of the installation process.
However, if I try to run activate, I get:
Error: could not find environment: cmd.exe
Environment not changed.
If I try to run conda install -n root -c pscondaenvs pscondaenvs again, or inside CMD I now get:
Error: HTTPError: 403 Forbidden http://repo.continuum.io/pkgs/pro/win-64/
Also, if I run activate in CMD once, I am able to run activate in the powershell from then on.
Any ideas? Happy to send any info that might help with debugging.
joaobarcia, please post a github bug report on my project so we can discuss there.
@darkdreamingdan you closed your project's issue tracker, you might need to open it up.
Is there currently an open PR for a fix? All earlier references I can find have been closed, and I'm not able to track those to any new PRs.
Not that I'm aware of.
There have been several PRs, but none have implemented this in a way that we think is wise. Activation is more than just modifying PATH - it's also running other scripts in the etc/conda/activate.d folder. Any accepted solution needs to do everything that the current activate.bat script does:
The latter point there is tricky. Since powershell support is so new, it would be nice if the powershell scripts also supported .bat files in the absence of any similarly-named .ps1 file. Some packages, such as GDAL, depend on these scripts to set environment variables.
@kalefranz has done a ton of work to rework how activation scripts work in the 4.4.x branch. It may be worth postponing any further effort on powershell until 4.4.x gets out of pre-release and into common usage. It's much faster and simpler with regards to this activation stuff.
@h404bi, the development continued at https://github.com/BCSharp/PSCondaEnvs, post your issues there. At my end, I cannot reproduce the issue reported by @joaobarcia using the latest version.
@msarahan, PSCondaEnv does just what you mention, although it can be improved (esp. in speed). I am looking forward to the rework of activation in 4.4.
@BCSharp that looks very refined. Nice work - especially on the .bat file fallback. Do you mind putting up a PR against the 4.3.x branch? I guess the only annoying part left might be getting the test suite to run against your scripts.
The bug @joaobarcia posted was already resolved on my fork https://github.com/darkdreamingdan/PSCondaEnvs/issues/1 where the bat functionality came from in the first place 😕
Sorry for any credit misassignment. Having done a lot of work on the bat and shell activation scripts, I admire what you all have done with the powershell stuff. I've been off of this stuff for not quite 2 years now, so please forgive my ignorance of who has done what.
If anyone following this thread would like to contribute, https://github.com/conda/conda/pull/6471 sketches out the start of what a powershell wrapper might look like under the conda 4.4+ framework. The https://github.com/conda/conda/pull/6471 PR has additional instruction and comments. A new PR that follows the same patterns established by the five other shell wrappers, and as sketched out in #6471, would be very welcome.
bump desperately seeking Powershell support
There’s a PR now that’s close!
Sent from my iPhone
On Sep 24, 2018, at 11:58 AM, Mus. notifications@github.com wrote:
bump desperately seeking Powershell support
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Resolved by https://github.com/conda/conda/pull/7794. Will be included in conda 4.6.
This is still messed up with Powershell with current anaconda version.
conda 4.6 is not released yet, please be patient.
On Wed, Oct 10, 2018 at 5:54 PM rhaejr notifications@github.com wrote:
This is still messed up with Powershell with current anaconda version.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/conda/conda/issues/626#issuecomment-428648732, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA_pdDr8cqJxd7vb2J0lDxtN6k7imrmwks5ujiZAgaJpZM4Btxzz
.
@mingwandroid Any progress? I recently downloaded anaconda 5.3, but activate is still not working with ps. Or is there some trick?
It'll be part of conda 4.6 I think. I cannot give a reliable timeline for that at present though, sorry.
https://www.anaconda.com/blog/developer-blog/conda-4-6-release/
Looks like it made it in
https://www.anaconda.com/blog/developer-blog/conda-4-6-release/
The link is broken. Here's the working one https://www.anaconda.com/conda-4-6-release/
Still, great job, guys!
Correct me if I'm wrong, with the current solution (conda 4.6) an instance of python runs at startup of any Powershell process querying for the active environment, and its name is printed at the beginning of the prompt. This does not seem optimal because it slows down the loading of the shell even if the user is not interested in actually working with conda. The implementation in cmd seems to be better because conda runs only when actively requested by the user (via conda activate) and information about the environment disappears when no longer needed (deactivate). Shouldn't it behave in the same way in Powershell?
@giuliofoletto I think it would be better if you opened up a new issue for discussing possible enhancements to the current implementation of this. Having a new, open issue should help with visibility of your concerns.
Conda version: conda 4.6.11
Windows 10
Looks like the conda activate
And if you install new packages, assuming that you are actually installing in the new_env, it will install in the base env. So, please beware!
e.g. I did the following:
1.
conda env list >>
base * C:UsersabcdAppDataLocalContinuumanaconda3
envp3 C:UsersabcdAppDataLocalContinuumanaconda3envsenvp3
2.
conda activate envp3
conda env list >>
base * C:UsersabcdAppDataLocalContinuumanaconda3
envp3 C:UsersabcdAppDataLocalContinuumanaconda3envsenvp3
Another issue:
If I do _conda init powershell_>>
then restarting my powershell, ps is getting initialized with base env. Now if I want to activate envp3, it is crashing. same with deactivate.
Let me know if I am doing anything wrong.
Having the same issue on Win10 with powershell after running conda init powershell. Conda 4.6.11 as well.
https://github.com/Liquidmantis/PSCondaEnvs. No longer supports.
Most helpful comment
I've been building on BCSharp's excellent work at my own repo (currently on PR).
Just do:
conda install -n root -c pscondaenvs pscondaenvsYou need Conda 4.1 or above (check with
conda info conda) - otherwise please install the latest version.Behavior is exactly like CMD - use
activateordeactivateappropriately. It's completely backwards compatible and will also launch both .ps1 and .bat activate.d/deactivate.d scripts.