regisf / virtualenvwrapper-powershell

A mimic of the VirtualEnvWrapper project but with Powershell
MIT License
109 stars 28 forks source link

Python path contains (x86) #9

Closed lepsalex closed 4 years ago

lepsalex commented 5 years ago

Attempting to run mkvirtualenv __name_of_env__ when the python path contains "Program Files (x86)" results in an error: The term 'x86' is not recognized as the name of a cmdlet ....

I have a branch with a fix and can open a PR if you'd like, diff output below:

diff --git a/VirtualEnvWrapper.psm1 b/VirtualEnvWrapper.psm1
index f3b43dd..76d210d 100644
--- a/VirtualEnvWrapper.psm1
+++ b/VirtualEnvWrapper.psm1
@@ -73,7 +73,7 @@ function Get-PythonVersion($Python) {
         return
     }

-    $python_version = Invoke-Expression "$Python --version 2>&1"
+    $python_version = Invoke-Expression "& '$Python' --version 2>&1"
     if (!$Python -and !$python_version) {
         Write-Host "I don't find any Python version into your path" -ForegroundColor Red
         return
@@ -130,7 +130,7 @@ function New-Python3Env($Python, $Name) {
         $PythonExe = Join-Path (Split-Path $Python -Parent) "python.exe"
     }

-    $Command = "$PythonExe -m venv"
+    $Command = "& '$PythonExe' -m venv"

     Invoke-CreatePyEnv $Command $Name
 }
regisf commented 5 years ago

I was in holidays. Could you please send me your PR ? I will evaluate it as soon as possible. Thank you.