question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OSError when creating virtualenv symlinking in Vagrant

See original GitHub issue

The issue

Using pipenv in a vagrant box is causing a little trouble with the symlinking. It has been requested that --always-copy is added to pipenv when it creates the virtual environment see ( #1929) but it appears that is not gonna happen 😞

The error

Using /usr/bin/python3.6m (3.6.5) to create virtualenv…
Running virtualenv with interpreter /usr/bin/python3.6m
Using base prefix '/usr'
New python executable in /vagrant/project/thing/.venv/bin/python3.6m
Also creating executable in /vagrant/project/thing/.venv/bin/python
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/virtualenv.py", line 2349, in <module>
    main()
  File "/usr/local/lib/python3.6/dist-packages/virtualenv.py", line 712, in main
    symlink=options.symlink)
  File "/usr/local/lib/python3.6/dist-packages/virtualenv.py", line 927, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/local/lib/python3.6/dist-packages/virtualenv.py", line 1395, in install_python
    os.symlink(py_executable_base, full_pth)
OSError: [Errno 71] Protocol error: 'python3.6m' -> '/vagrant/project/thing/.venv/bin/python'

Environment variables

export PIPENV_VENV_IN_PROJECT=1
export PIPENV_IGNORE_VIRTUALENVS=1

commands to fix it

pipenv sync # Fails with OSError listed above
virtualenv --always-copy .venv
pipenv sync # Success!

Seen in vagrant box: ubuntu/xenial64 and ubuntu/bionic64

I hope it helps someone who got stuck with this like I did

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
techalchemycommented, Apr 29, 2018

@Inveracity I wouldn’t say ‘it appears its not gonna happen’, the issue in question was closed because a simple solution was found that didn’t require api changes on our end. If that’s not true in this case we can revisit it, although I was under the impression that this is automatically toggled for windows virtualenv creation anyway…

Either way, you can also just set the environment variable VIRTUALENV_ALWAYS_COPY=1 and this will be toggled on at creation… closing for now, but let me know if this doesnt work

2reactions
Inveracitycommented, Apr 29, 2018

@uranusjr It is indeed Vagrant running on windows

@techalchemy it works! thank you so much!

tested it doing:

export VIRTUALENV_ALWAYS_COPY=1
pipenv sync # success
pipenv --rm
export VIRTUALENV_ALWAYS_COPY=0
pipenv sync # fail as expected
Read more comments on GitHub >

github_iconTop Results From Across the Web

protocol error setting up virtualenvironment through vagrant ...
I'm trying to set up a virtualenv on Ubuntu 12.04 with Python 2.7 using vagrant but having same issues. it seems like this...
Read more >
Protocol error on trying to run bench init on a vagrant machine ...
I have a dual boot windows and ubuntu machine. When working from windows, I sometimes use a vagrant based virtual machine.
Read more >
Unable to create a sample RA as per the steps mentioned in ...
Error while preparing the virtual environment for the new RA: vagrant@vagrant:~/shared/MyRA$ make prepare-venv. New python executable in ...
Read more >
Add recommended VM setup steps for Windows users to ...
4) Hit "oserror: [errno 71] protocol error" when create-test-environment tries to make the venv ... (.venv)vagrant@vagrant-ubuntu-trusty-64:/vagrant$ .
Read more >
OSError: [Errno 17] File exists: virtualenv on python. – iTecNote
pythonvirtualenv. I am working on window 10 os. I use vagrant for my python environment. But when I try to create new virtualenv...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found