5

I was using the command virtualenv --no-site-packages django-env but I encountered the following error

Traceback (most recent call last): File "/usr/local/bin/virtualenv", line 9, in <module> load_entry_point('virtualenv==12.0.7', 'console_scripts', 'virtualenv')() File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 825, in main symlink=options.symlink) File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 985, in create_environment site_packages=site_packages, clear=clear, symlink=symlink)) File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 1416, in install_python os.symlink(py_executable_base, full_pth) OSError: [Errno 1] Operation not permitted 

So I thought using the command sudo virtualenv --no-site-packages django-env on my terminal to avoid any operating system conflicts, but it throws the following error please have a look at that

Traceback (most recent call last): File "/usr/local/bin/virtualenv", line 9, in <module> load_entry_point('virtualenv==12.0.7', 'console_scripts', 'virtualenv')() File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 825, in main symlink=options.symlink) File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 985, in create_environment site_packages=site_packages, clear=clear, symlink=symlink)) File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 1204, in install_python copyfile(stdinc_dir, inc_dir, symlink) File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 479, in copyfile copyfileordir(src, dest, symlink) File "/usr/local/lib/python2.7/dist-packages/virtualenv-12.0.7-py2.7.egg/virtualenv.py", line 454, in copyfileordir shutil.copytree(src, dest, symlink) File "/usr/lib/python2.7/shutil.py", line 208, in copytree raise Error, errors shutil.Error: [('/usr/include/python2.7/numpy', 'django-env/include/python2.7/numpy', '[Errno 1] Operation not permitted')] 

I am using Ubuntu 14.04 and Python 2.7.6

I am unable to figure what is causing the error.

5
  • Why are you running it using sudo? You really don't need to do that. Commented Feb 21, 2015 at 20:56
  • I was running without sudo but this error came Traceback (most recent call last): File "/usr/local/bin/virtualenv", line 9, in <module> load_entry_point('virtualenv==12.0.7', 'console_scripts', 'virtualenv')() OSError: [Errno 1] Operation not permitted Commented Feb 21, 2015 at 21:02
  • wait I am updating the question either Commented Feb 21, 2015 at 21:04
  • How you install virtualenv? As I see it's probably by pip or easy_install. Did you upgrade your ubuntu from older one and the virtualenv was installed on the older one? Commented Feb 23, 2015 at 20:49
  • 1
    The issue was not with the Ubuntu , I have found it out it was the problem of the USb drive , I have to provide the media ownership then only it would work on the device. Commented Feb 28, 2015 at 5:33

5 Answers 5

6

By default, VirtualBox will forbid creating symlinks in mounted shared folders due to the security reasons.

You can however, enable it yourself manually using the following command.

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

After that virtual environment should be bootstrapped correctly. Do not forget to shutdown the VM for this setting to be picked up.

You can refer to this VirtualBox's ticket for more details: https://www.virtualbox.org/ticket/10085.

Sign up to request clarification or add additional context in comments.

1 Comment

seems to need a reboot of the vbox but this worked for me Virtualbox 6.1 on Mac + Ubuntu 20 client
5

Regarding ownership of the development folder:

I had a similar error when running virtualenv on a virtualbox mounted drive. Switching over to a directory on the virtual machine ran fine.

All the best.

Comments

3

I had a similar error when running virtualenv on a mounted drive. For me "--always-copy" option resolved the issue.

Comments

2

If you're using venv module (like you're supposed to nowadays), create the virtual environment in some nonshared folder. The stupid feature of that module is even if you specify --copies flag, it still tries to create symlinks, but between two folders in the same directory.

Create the virutal environment in a non-shared folder between your vm and host, remove the symlink and duplicate the lib folder via copy or another command.

1 Comment

I was in a Docker container, and tried to make a venv. It failed because I was in a folder mounted to the container. Moving out of that allowed me to make a venv with no errors.
0

On your home try these commands

1.sudo easy_install virtualenv
2.mkdir virt_env
3.virtualenv virt_env/test1
4.source test1/bin/activate
5.pip install django==1.7.4

after that
django-admin.py startproject project_name

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.