Python 3.x virtualenv: Unable to create process

I am not able to use venv in windows for some reason:

I am using Python in Windows.
I can create a virtual environment, but I cannot use pip there.
I am after:

  • uninstall all python3
  • install python 3.7 32bit
PS I:\2> py -0p
Installed Pythons found by C:\WINDOWS\py.exe Launcher for Windows
 -3.7-32        C:\Users\ltyrala\AppData\Local\Programs\Python\Python37-32\python.exe *
 -2.7-32        C:\Python27\python.exe

PS I:\2> py -3.7 -m venv tets
PS I:\2> . .\tets\Scripts\Activate.ps1
(tets) PS I:\2> pip
Fatal error in launcher: Unable to create process using '"i:\2\tets\scripts\python.exe"  "I:\2\tets\Scripts\pip.exe" '

(tets) PS I:\2> echo $env:Path
I:\2\tets\Scripts;C:\Users\ltyrala\AppData\Local\Programs\Python\Python37-32;C:\Users\ltyrala\AppData\Local\Programs\Python\Python37-32\Scripts;C:\Python27;C:\Python27\Scripts; # ...

(tets) PS I:\2> systeminfo
# ...
OS Name:                   Microsoft Windows 10 Enterprise
OS Version:                10.0.19042 N/A Build 19042
# ...

if I will do the same in BATCH, pip does not instal into environment:

I:\2>tets\Scripts\activate.bat

(tets) I:\2>pip
Usage:
  pip <command> [options]
# ...

(tets) I:\2>pip install psutil
pypi/simple
# ...

(tets) I:\2>dir C:\Users\ltyrala\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
09/24/2021  12:43 PM    <DIR>          psutil
09/24/2021  12:43 PM    <DIR>          psutil-5.8.0.dist-info

(tets) I:\2>dir tets\Lib\site-packages\
 Volume in drive I is Windows
 Volume Serial Number is B2B1-8D64

 Directory of I:\2\tets\Lib\site-packages

09/24/2021  12:11 PM    <DIR>          .
09/24/2021  12:11 PM    <DIR>          ..
09/24/2021  12:11 PM               126 easy_install.py
09/24/2021  12:11 PM    <DIR>          pip
09/24/2021  12:11 PM    <DIR>          pip-19.2.3.dist-info
09/24/2021  12:11 PM    <DIR>          pkg_resources
09/24/2021  12:11 PM    <DIR>          setuptools
09/24/2021  12:11 PM    <DIR>          setuptools-41.2.0.dist-info
09/24/2021  12:11 PM    <DIR>          __pycache__
               1 File(s)            126 bytes
               8 Dir(s)  227,334,418,432 bytes free

Any suggestions on what may be wrong?

1 Like

Hi Łukasz,

some questions that come to mind:

  • Does I:\2\tets\Scripts\pip.exe exist?

  • Can you run python in the venv? Are sys.path and sys.executable set correctly?

  • If python works as expected, does python -m pip work?

  • You showed that you can run pip in the classic NT cmd prompt. What is that actually running? Try where pip

  • Why are you using Python 3.7 and not Python 3.9?

Maybe some of these lead somewhere useful.

1 Like
  • Does I:\2\tets\Scripts\pip.exe exist?
    yes
(tt) I:\2>I:\2\tt\Scripts\python.exe -c "import sys; print(sys.executable)"
I:\2\tt\Scripts\python.exe
  • Can you run python in the venv ? Are sys.path and sys.executable set correctly?
(tt) I:\2>I:\2\tt\Scripts\python.exe -c "import sys; print(sys.path)"
['', 'C:\\Users\\ltyrala\\AppData\\Local\\Programs\\Python\\Python37-32\\python37.zip', 'C:\\Users\\ltyrala\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs', 'C:\\Users\\ltyrala\\AppData\\Local\\Programs\\Python\\Python37-32\\lib', 'C:\\Users\\ltyrala\\AppData\\Local\\Programs\\Python\\Python37-32', 'I:\\2\\tt']
  • If python works as expected, does python -m pip work?
    no
(tt) PS I:\2> python -m pip
I:\2\tt\Scripts\python.exe: No module named pip
(tt) PS I:\2> pip
Fatal error in launcher: Unable to create process using '"i:\2\tt\scripts\python.exe"  "I:\2\tt\Scripts\pip.exe" '
  • You showed that you can run pip in the classic NT cmd prompt. What is that actually running? Try where pip
(tt) I:\2>where pip
I:\2\tt\Scripts\pip.exe
C:\Users\ltyrala\AppData\Local\Programs\Python\Python37-32\Scripts\pip.exe
C:\Python27\Scripts\pip.exe
  • Why are you using Python 3.7 and not Python 3.9?
    I have such requirements from my project.

My friends for this project have this environment working.
I am out of ideas, I will load clean windows image :smiley:

1 Like

There’s your answer as to what the error is: pip isn’t properly installed in the venv. I have no idea how this could have happened, but you could see if python -m ensurepip does anything useful

1 Like