Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtualenv not creating an environment

I installed Virtualenv on Ubuntu 12.04 and was using it to work on a sample project under the unity desktop. I'm using VirtualBox and was having some issues with the unity desktop so changed to the KDE desktop.

I'm now trying to create a new project but the virtualenv won't allow me to create a new environment in my project folder. In the terminal I navigate to the project folder, type virtualenv venv and get the following error messages:

Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 3, in <module>
    virtualenv.main()
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 938, in main
    never_download=options.never_download)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1039, in create_environment
    site_packages=site_packages, clear=clear))
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1215, in install_python
    copyfile(stdinc_dir, inc_dir)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 430, in copyfile
    copyfileordir(src, dest)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 405, in copyfileordir
    shutil.copytree(src, dest, True)
  File "/usr/lib/python2.7/shutil.py", line 206, in copytree
    raise Error, errors
shutil.Error: [('/usr/include/python2.7/numpy', 'venv/include/python2.7/numpy', '[Errno 30] Read-only file system')]

Can anyone help me resolve this? I've tried reinstalling virtualenv but no joy. Thanks

like image 341
adohertyd Avatar asked Jun 29 '12 15:06

adohertyd


People also ask

How do I activate virtualenv activation?

To activate virtualenv on Windows, first, install the pip. For this purpose, you can download and execute the latest Python installer. Next, install and create virtualenv on Windows using the pip package manager. Then, activate it using the “venvironment\Scripts\activate” command.


2 Answers

Virtualenv is using symbolic links (shutil.copytree uses them, see traceback). Creating symbolic links in a VirtualBox shared folder is disabled. Simple test in terminal (inside the guest machine):

$ ln -s testfile

Either you'll get a failed to create symbolic link './testfile': Read-only file system or Protocol error.

You can enable symbolic links in shared folders by executing in terminal on the host (solution from schisamo):

$ vboxmanage setextradata VM_NAME "VBoxInternal2/SharedFoldersEnableSymlinksCreate/NAME_OF_YOUR_SHARED_FOLDER" 1

Replace VM_NAME with the name of the virtual machine, as seen in the VirtualBox Manager:

VM_NAME example

and NAME_OF_YOUR_SHARED_FOLDER with the name of the shared folder which you can see in the settings of the virtual machine:

Shared folders settings

After the setting, restart the VirtualBox.

You can check the settings (on the host) with

$ vboxmanage getextradata VM_NAME enumerate

Fix for Windows (Ahti Kitsik) (thanks to Bryan's answer).


VirtualBox implemented symbolic links for shared folders since version 4.0 (for Linux and Solaris) but are disabled since version 4.1.8 for security reasons. That may be the reason why it first worked for you and later not.

Documentation:

VirtualBox shared folders also support symbolic links, also called symlinks, under the following conditions:

  • The host operating system must support symlinks. For example, a Mac OS X, Linux, or Oracle Solaris host is required.
  • Currently only Linux and Oracle Solaris Guest Additions support symlinks.
  • For security reasons the guest OS is not allowed to create symlinks by default. If you trust the guest OS to not abuse the functionality, you can enable creation of symlinks for a shared folder as follows [see above]
like image 99
Dominik Avatar answered Oct 14 '22 07:10

Dominik


Ok after a bit more in-depth googling found that this is a VirtualBox issue, not a Ubuntu problem. The shared folders are protected from this activity. I don't know how/why it worked the first time round but it is a known bug. I created a project outside of the shared folder with no problems. Thanks for the input Dougal.

like image 23
adohertyd Avatar answered Oct 14 '22 08:10

adohertyd