9

I am trying to get virtualenv[wrapper] to work on my Windows machine through Cygwin. The install is successful, together with easy_install, based on these directions: http://www.doughellmann.com/docs/virtualenvwrapper/.

The problem comes in when I use the mkvirtualenv [name_of_vir_env]. I get the following output:

$ mkvirtualenv testenv
New python executable in testenv\Scripts\python.exe
Installing setuptools.................done.
bash: D:\.virtualenvs/testenv/bin/postactivate: No such file or directory
chmod: getting attributes of `D:\\.virtualenvs/testenv/bin/postactivate': No such file or directory
bash: D:\.virtualenvs/testenv/bin/predeactivate: No such file or directory
chmod: getting attributes of `D:\\.virtualenvs/testenv/bin/predeactivate': No such file or directory
bash: D:\.virtualenvs/testenv/bin/postdeactivate: No such file or directory
chmod: getting attributes of `D:\\.virtualenvs/testenv/bin/postdeactivate': No such file or directory
ERROR: Environment 'D:\.virtualenvs/testenv' does not contain an activate script.

Inside the testenv directory, there is no bin subdirectory, rather only Lib and Scripts. Scripts contains activate.bat which is supposed to be used to activate this particular environment, however if I try to run this out through bash I get an error:

$ ./activate.bat
./activate.bat: line 1: @echo: command not found
./activate.bat: line 4: syntax error near unexpected token `('
./activate.bat: line 4: `if not defined PROMPT ('

I can exit bash and call activate.bat and this changes to the desired environment. But then not being in bash I cannot use the workon command, or any other in virtualenvwrapper_bashrc.

How can I get the two to work together, that is, stay in bash so I can use the commands in virtualenvwrapper_bashrc?

4 Answers 4

3

I'm not experienced with virtualenvwrapper, but do use virtualenv regularly. I don't think the activate.bat is intended to be run under cygwin, it works when run in the regular windows shell. I think if you are using cygwin, you might want to use something more like bin/activate(the version for unix-like OS's).

The cygwin environment within bash could be drastically different from the standard environment activate.bat expects to run in, so finding an activate script that would work with bash(perhaps find a copy from a unix version) would probably get you to where you can run your virtualenv within bash.

1
  • Had to use . venv/scripts/activate
    – Jabez
    Oct 30, 2013 at 6:04
1

This post looks promising http://atbrox.com/2009/09/21/how-to-get-pipvirtualenvfabric-working-on-cygwin/

-- Quentin

1
  • Sadly it uses cygwin's own Python, which as of Sept 15 '12 is only Python 2.6.8 at the highest. Sep 15, 2012 at 17:51
1

This did it for me:

https://bitbucket.org/cliffxuan/virtualenvwrapper-for-cygwin-windows-python

The vanilla virtualenvwrapper does not seem to support the Cygwin environment.

A caveat however is that executable scripts under the Scripts directory of the virtualenv are only executable if you pass them explicitly to the python command and don't use ~ or anything else that Cygwin implicitly converts a path starting with /cygdriv/c/...—the native Windows Python cannot see those paths.

0

I don't know virtualenv, but I'm seeing what looks like a classic mixed path syntax issue from cygwin:

Your string is:

D:\.virtualenvs/testenv/bin/predeactivate

but Cygwin is interpreting the backslash as an escape for the "." character, producing:

D:.virtualenvs/testenv/bin/postactivate

which is in the error text you're quoting and is obviously a malformed path. Check your actual environment variable - it's probably in DOS/Windows path syntax, while the internal part is in cygwin/unix syntax.

If so, try using os.path.join to splice the two parts together and see if you get a consistent syntax out of that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.