5

Apologies if this is a basic question:

I have been trying to setup Python on my laptop by following the tutorial here. Under PIP, VIRTUALENV + VIRTUALENVWRAPPER subtitle, it says

  1. And now setup virtualenvwrapper:

    1 $ export WORKON_HOME=$HOME/.virtualenvs
    
    2 $ export MSYS_HOME=/c/msys/1.0
    
    3 $ source /usr/local/bin/virtualenvwrapper.sh
    

The last line of above gives me the following error:

$ source /usr/local/bin/virtualenvwrapper.sh
sh.exe": /usr/local/bin/virtualenvwrapper.sh: No such file or directory

So when I test my setup I get the following error:

$ mkvirtualenv TestEnv
sh.exe": mkvirtualenv: command not found

Could some1 help me out please?

THis is all on a Win7 laptop.

Thanks.

matcheek
  • 4,887
  • 9
  • 42
  • 73
Has
  • 885
  • 4
  • 13
  • 31

4 Answers4

9

From what you wrote it looks to me that you are mixing Windows and Linux shell commands.

I strongly advocate you get the virtualenv working first before you turn to a wrapper

To get virtualenv on Windows 7

pip install virtualenv

then

virtualenv name_to_your_env

name_to_your_env\Scripts\activate
matcheek
  • 4,887
  • 9
  • 42
  • 73
  • For the second part, I get the following error: $ nameOfEnv\bin\activate sh.exe": nameOfEnvbinactivate: command not found – Has Sep 08 '13 at 13:56
  • Did you run on on windows command line? "$" at the start which I have just noticed suggests the you are running some shell that you did not mention directly in the question. The command should be run directly in the windows command line – matcheek Sep 08 '13 at 15:10
  • Iccc! THank you sooo much! Yep that works! SO every time i create a virtual env, I have to do name_to_your_env\Scripts\activate ? THanks. – Has Sep 08 '13 at 15:29
  • Yea I was running in the shell because in the tutorial i was following here http://newcoder.io/begin/setup-your-machine/#windows , all the commands began with a $ – Has Sep 08 '13 at 15:30
  • Yes, as far as virtualenv is concerned, you have to run it once for every virtual environment you create. Happy that it worked for you. – matcheek Sep 08 '13 at 15:31
  • 1
    The issue may persist when using git bash. Switch to the native command prompt – kakoma Nov 08 '16 at 14:01
5

I was having this same problem but got it to work a different way in Windows.

pip install virtualenv
virtualenv venv

.\venv\Scripts\activate.bat

The key here is running activate.bat rather than just activate. Once I did this and closed and opened cmd again and tried the normal

.\venv\Scripts\activate

it worked. I don't know why but it worked for me, hopefully it helps somebody else.

smoosh911
  • 516
  • 7
  • 8
3

According to your comment, virtualenvwrapper.sh is not in /usr/local/bin.

You should pass correct path to source command.

source /path/to/..../Scripts/virtualenvwrapper.sh
falsetru
  • 357,413
  • 63
  • 732
  • 636
  • I get this when I do the above: '$ source /path/to/..../Scripts/virtualenvwrapper.sh sh.exe": /path/to/..../Scripts/virtualenvwrapper.sh: No such file or directory' – Has Sep 08 '13 at 13:53
  • 2
    @Hasnain, `/path/to/..../Scripts/virtualenvwrapper.sh` is just a example. You should specify real path. – falsetru Sep 08 '13 at 13:56
  • Oh I see! Apologies. Where can i find the real path? Thanks. – Has Sep 08 '13 at 14:22
  • @Hasnain, Try `python -c "import os; print os.path.abspath('..\..\..\Scripts\virtualenvwrapper.sh')"` in the directory where you did run the `pip show ...` command. It will tell you absolute path of the shell script. – falsetru Sep 08 '13 at 14:25
  • Hi, I believe it is c:/Python27/Scripts/virtualenvwrapper.sh. So i did source c:/Python27/Scripts/virtualenvwrapper.sh. I still get $ source c:/Python27/Scripts/virtualenvwrapper.sh sh.exe": mktemp: command not found ERROR: virtualenvwrapper could not create a temporary file name. – Has Sep 08 '13 at 14:38
0

I had encountered with the same problem and solved it by downloading mktemp binary for windows and uncompressing it under git/bin. Then it works. (I was trying to run leiningen [lein help] command under Git Bash, on Windows 7)

This is the download site i visited.

Riad
  • 3,822
  • 5
  • 28
  • 39