Solvedcmder Virtualenv in Powershell cannot be activated
โ๏ธAccepted Answer
I face the same problem.
Thanks.
I confirm that removing -Options ReadOnly
from Set-Item -Path function:\prompt -Value $Prompt -Options ReadOnly
.
virtualenv
prompt is back.
If anyone don't know where it is, go to vendor/profile.ps1
.
I just write more detail.
Hope anyone who face this issue may see my comment and found that line quickly.
Other Answers:
The last cmder added some protection from anything overwriting global:prompt
because I was a little concerned about any script running to hijack it.
Fix virtualenv
If you use virtualenv set $env:VIRTUAL_ENV_DISABLE_PROMPT = 1
all it does is print your projects folder, you've already got that in the console anyway. Tested on python 3.6.
$env will do the current process. Set a user env variable or add $env:VIRTUAL_ENV_DISABLE_PROMPT = 1
to user-profile.ps1
Workaround venv
A quick test and python -m venv
seems to ignore $env:VIRTUAL_ENV_DISABLE_PROMPT = 1
and it writes the prompt anyway.
So it looks like you have two options;
- Remove the function global:prompt from
activate.ps1
- Comment out
-options readonly
from setting the prompt in cmder profile for now and it will let you clobber function:\prompt again. - use virtualenv with the above fix.
I'll have to have a think how to accommodate virtualenv. Going to leave this issue open I think until an update is in the works.
Had the same problem, but I was able to fix it with just commenting the -Options ReadOnly
portion only, leaving the rest how it was.
But don't know if it is the right way
On the latest version, when I run the Activate.ps1 script to enable the virtualenv, Cmder throws the following error. Virtualenvs work fine on regular PowerShell.