Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activating pyvenv from gitbash for windows

I use gitbash on windows (7, 64bit). I tried to create a venv using python 3.4's built-in venv module by calling python -m venv venv, and it created successfully, but the resultant venv does not contain a bash activate script, only a .bat and .ps1.

The virtualenv library for python 2.6.6 (version 13.0.1) created the following four files in the venv/Scripts/ folder: activate, activate.bat, activate.ps1, and activate_this.py.

As the gitbash console cannot use the bat or powershell scripts, and I don't really want to have to move back to the windows cmd prompt or to a VM, is there any way I can get pyvenv to create a shell script for me while I'm on windows?

like image 217
bbm Avatar asked Jun 01 '15 15:06

bbm


3 Answers

There were lots of confusion in many answers and comments here. Some of them said you can simply do . activate, some (@nme) said "You'll get the "No such file or directory" error then since there is only activate.bat and Activate.ps1 which both don't work."

The problem did exist, as documented in this issue. And that issue was eventually fixed at Jan 2017 in Python 3.5.x, 3.6.x onward. Therefore, ONLY Python 3.5.3+, 3.6.1+, 3.7 released AFTER Jan 2017 would have fixed such issue. Possibly Python 2.7.14+ too. This means, if you are still reading this Q&A page, the first thing you would need to do is to check which version of Python you are using, and then probably do an upgrade. (For example, I encountered same issue with one of my old Python 3.6.0 environment, and after upgrading to Python 3.7.2, the problem is gone.)

like image 110
RayLuo Avatar answered Sep 19 '22 17:09

RayLuo


You do not have to worry about the presence of virtual env bash script go to Git bash and use . Scripts/activate or source Scripts/activate as mentioned in answer in this topic Can not activate a virtualenv in GIT bash mingw32 for Windows

like image 43
Nwawel A Iroume Avatar answered Sep 20 '22 17:09

Nwawel A Iroume


this worked for me:

. activate
like image 31
Diego Santa Cruz Mendezú Avatar answered Sep 19 '22 17:09

Diego Santa Cruz Mendezú