Question

In brief, my problem is that when I try to create a virtualenv using mkvirtualenv from virtualenvwrapper, I get the following error:

$ mkvirtualenv test
New python executable in test/bin/python
ERROR: The executable test/bin/python could not be run: [Errno 13] Permission denied

However, when I look at the permissions for the binary, as far as I can tell, everything should be fine...

$ ll ~/.virtualenvs/test/bin
total 2604
drwxr-xr-x 1 (username) staff       5 Feb  7 19:10 ./
drwxr-xr-x 1 (username) staff       5 Feb  7 18:51 ../
-rwxr-xr-x 1 (username) staff 2655776 Feb  7 19:10 python*
lrwxrwxrwx 1 (username) staff       6 Feb  7 19:10 python2 -> python*
lrwxrwxrwx 1 (username) staff       6 Feb  7 19:10 python2.7 -> python*

I get similar errors when I try to run as root:

$ sudo .virtualenvs/test/bin/python
sudo: unable to execute .virtualenvs/test/bin/python: Permission denied

I'm running Lubuntu 12.10 on my macbook, alongside Mountain Lion, and have set up a partition to use as a shared home directory between the two installs, roughly following the instructions here (http://mikeclaffey.com/dual-boot-osx-ubuntu/). As far as I can tell, this is all working correctly, both in ubuntu and mountain lion, but I mention it just because it means my lubuntu installation isn't strictly standard.

I've installed python-setuptools and python-dev using apt-get, then used sudo easy_install pip to get pip-1.2.1, followed by sudo pip install virtualenv virtualenvwrapper, to get virtualenv-1.8.4 and virtualenvwrapper-3.6.

Further particulars: I've created .virtualenvs in my home directory, and added:

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME

to my .bashrc.

Also, I have tried using sudo apt-get install python-pip instead of easy_install (this installs pip-1.1, rather than pip-1.2.1), but get the same permission errors.

Any help would be very much appreciated!

Était-ce utile?

La solution

It turns out the problem was to do with how I'd mounted my shared partition. I'd mounted with (in /etc/fstab):

UUID=....  /home   hfsplus   auto,user,nodev,rw    0    0

However, the 'user' option automatically includes 'noexec' --- thus, after virtualenv had copied the system python binary to my home partition, it was unable to run because of the 'noexec' flag.

Changing my fstab to read:

UUID=....  /home   hfsplus    auto,user,exec,nodev,rw   0   0

solved the problem.

Autres conseils

I have had the same problem. I tried creating a virtualenv in my home folder and that worked fine, but I got that error when I tried to create one on a different partition.

So to fix your problem either try a different location or take a look at how stuff is mounted.

As the other answers (thankfully) have already stated, it is a permissions issue. I resolved it by re-mounting the required drive with the correct exec permissions (as already pointed out). But I could not use @duncanm's anwer since I could not find my drive path in the /etc/fstab file.

I executed the following on my Ubuntu 14.04 and it did the job.

To unmount -

$ sudo umount /media/ashish/Work/

To mount back with correct permissions -

$ sudo mkdir /media/ashish/Work
$ sudo mount -o exec /dev/sda6 /media/ashish/Work/
$ cd /media/ashish/Work/

I figured out the /dev/sda6 part by looking at the properties tab in the file manager.

I believe it is primarily a problem with exec permissions, as you have discovered. You might also work around this by creating the virtualenv in a subdirectory of /data or /sd-ext. I am working on multiuser support, which puts home directories under /data/home rather than just the one sd card "home directory".

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top