mkvirtualenv with spaces in path

106 views
Skip to first unread message

Mike Beatty

unread,
Oct 5, 2014, 3:48:17 PM10/5/14
to virtuale...@googlegroups.com
Like other users, my Mac's home directory is on a secondary drive which results in a path with a space in it. e.g. /Volumes/Macintosh HD/Users/<username>/
I've found that when creating and activating the virtualenv, if I try to run pip I get a Bad Interpreter error because the shebang line in the pip script contains that path with a space. To get around this I created a symlink to /Users/<username> on my root drive and when I create a vrtualenv, i type out the full path to my virtualenv directory and it creates the shebang properly.
I was hoping that virtualenvwrapper would help be get around having to type the full path but unfortunately, even after adding
export WORKON_HOME="Users/<username>/Virtualenvs" to .bash_profile, the shebangs are created with the full /Volumes/Macintosh HD/ path.
Am I wrong in thinking that mkvirtualenv should honor the path in WORKON_HOME when creating the virtualenv? Is there some other way to force mkvirtualenv to user the symlink path?

Doug Hellmann

unread,
Oct 7, 2014, 9:04:52 AM10/7/14
to virtuale...@googlegroups.com
Looking at virtualenvwrapper_derive_workon_home, it seems like what you’re doing should work. Can you post the actual text from your login script?

Doug


Mike Beatty

unread,
Oct 7, 2014, 10:09:49 AM10/7/14
to virtuale...@googlegroups.com
Here's the virtualenvwrapper section in my .bash_profile

#Virtualenvwrapper settings
export WORKON_HOME=/Users/mike/Virtualenvs
export PROJECT_HOME=/Users/mike/Developer/Python
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
source /usr/local/bin/virtualenvwrapper.sh


Thanks
Mike B.

Doug Hellmann

unread,
Oct 8, 2014, 2:36:06 PM10/8/14
to virtuale...@googlegroups.com
On Oct 7, 2014, at 10:09 AM, Mike Beatty <mik...@gmail.com> wrote:

Here's the virtualenvwrapper section in my .bash_profile

#Virtualenvwrapper settings
export WORKON_HOME=/Users/mike/Virtualenvs
export PROJECT_HOME=/Users/mike/Developer/Python
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
source /usr/local/bin/virtualenvwrapper.sh

That definitely looks like it should be working.

I may be overly aggressive about normalizing the value. What is the value of $WORKON_HOME after your shell starts up? Is it being modified by the normalization steps, or is it correct?

Doug



Thanks
Mike B.

On Tuesday, October 7, 2014 8:04:52 AM UTC-5, Doug Hellmann wrote:

On Oct 5, 2014, at 3:48 PM, Mike Beatty <mik...@gmail.com> wrote:

> Like other users, my Mac's home directory is on a secondary drive which results in a path with a space in it. e.g. /Volumes/Macintosh HD/Users/<username>/
> I've found that when creating and activating the virtualenv, if I try to run pip I get a Bad Interpreter error because the shebang line in the pip script contains that path with a space. To get around this I created a symlink to /Users/<username> on my root drive and when I create a vrtualenv, i type out the full path to my virtualenv directory and it creates the shebang properly.
> I was hoping that virtualenvwrapper would help be get around having to type the full path but unfortunately, even after adding
> export WORKON_HOME="Users/<username>/Virtualenvs" to .bash_profile, the shebangs are created with the full /Volumes/Macintosh HD/ path.
> Am I wrong in thinking that mkvirtualenv should honor the path in WORKON_HOME when creating the virtualenv? Is there some other way to force mkvirtualenv to user the symlink path?

Looking at virtualenvwrapper_derive_workon_home, it seems like what you’re doing should work. Can you post the actual text from your login script?

Doug



--
You received this message because you are subscribed to the Google Groups "virtualenvwrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtualenvwrap...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Beatty

unread,
Oct 8, 2014, 3:54:59 PM10/8/14
to virtuale...@googlegroups.com
This is the output in my shell when I go through the steps of creating a new virtualenv and then running pip list. As you can see the WORKON_HOME variable is correct but for some reason the symlink is getting followed and expanded in the shebang line of the various scripts.

MacBookPro:~ mike$ echo $WORKON_HOME
/Users/mike/Virtualenvs
MacBookPro:~ mike$ mkvirtualenv testenv
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.4'
New python executable in testenv/bin/python3.4
Also creating executable in testenv/bin/python
Installing setuptools, pip...done.
(testenv)MacBookPro:~ mike$ pip list
-bash: /Volumes/Macintosh HD/Users/mike/Virtualenvs/testenv/bin/pip: "/Volumes/Macintosh: bad interpreter: No such file or directory
Reply all
Reply to author
Forward
0 new messages