Error setting up Vagrant with VirtualBox in PyChar

2019-03-22 22:38发布

问题:

When setting up the remote interpreter and selecting Vagrant, I get the following error in PyCharm:

Can't Get Vagrant Settings: [0;31mThe provider 'virtualbox' that was requested to back the machine 'default' is reporting that it isn't usable on this system. The reason is shown bellow: Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed. Vagrant uses the `VBoxManage` binary that ships with VirtualBox, and requires this to be available on the PATH. If VirtualBox is installed, please find the `VBoxManage` binary and add it to the PATH environment variable.[0m

Now, from a terminal, everything works. I can do 'up' and ssh into the VM without issues. Ports are forwarded as well as local files. So the issue is only in PyCharm. I have installed Java 1.8

PATH is: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

which VBoxManage: /usr/local/bin/VBoxManage and works in terminal.

Note that this is a fresh install of OS X done this morning. Vagrant version is 1.7.3, VirtualBox is 4.3.30 and PyCharm is 4.5.3

回答1:

Another workaround:

sudo ln -s /usr/local/bin/VBoxManage /usr/bin/VBoxManage

Edit:

Since it all worked some time ago, one of the following has to be cause of this problem:

  • either update of VirtualBox changed location of it's executable
  • or update of PyCharm changed PATH settings / executable location expectation for the IDE

Whatever the cause is, the solution is to make sure VBoxManage is in location expected by PyCharm. I haven't make up this solution myself, just googled it, but because it is so nice and clean I decided to add it here.



回答2:

Turns out, this problem is a known bug in PyCharm.

Until they fix it, you can get around the problem by launching PyCharm from a terminal window with the charm command.

Vagrant 1.7.3 and VirtualBox 4.3.30 under Pycharm 4.5: Path issue



回答3:

This helped me solve the issue:

https://github.com/Parallels/vagrant-parallels/issues/184

I can call this command where my vagrant file was located:

vagrant plugin update vagrant-parallels

Also, this link added some help for python paths

How to configure custom PYTHONPATH with VM and PyCharm?