Cannot runserver from Pycharm using Vagrant Interpreter. Path for manage.py is wrong, don't know where to fix it
I'm trying to configure correctly Pycharm (for a Django project) + Vagrant, to launch the runserver remotely from my host machine (and thus enable debugging).
The command for such seems simple but the path is wrong, so it fails.
It tries to run
/home/vagrant/.virtualenvs/[myprojname]/bin/python /vagrant/[myprojname]/manage.py runserver 0.0.0.0:8000
Second parameter is wrong, it's missing either the initial /home/ or it isn' a relative path.
I'm running a host windows machine, and a vagrant ubuntu 20.10 guest VB. I setup my remote interpreter with what I suppose are the right parameters.
In my vagrantfile I have setup the shared folder as following (Project name is PoeMogul) config.vm.synced_folder "PoeMogul", "/home/vagrant/PoeMogul"
- In my vagrant box, everything is setup fine (I think). I have my venv. In my /home/vagrant/PoeMogul dir i can see my working directory from PyCharm. I can manually (through vagrant ssh) run the server. But i cannot make Pycharm invoke the manage.py file correctly, it tries to access "/vagrant/..." and not "/home/vagrant/...".
To resolve the issue with the incorrect path in PyCharm, you should specify the correct path to the Python interpreter and the Django project in the Run Configuration.
In PyCharm, go to Run > Edit Configurations.
Click the plus sign (+) to create a new configuration, and select Django Server.
Give the configuration a name, such as "Vagrant Django Server".
In the Environment section, select the remote interpreter that you set up for your Vagrant virtual machine.
In the Host field, enter the IP address of the Vagrant machine, 0.0.0.0.
In the Port field, enter 8000.
In the Working directory field, enter the absolute path to your Django project in the Vagrant virtual machine, e.g. /home/vagrant/PoeMogul.
In the manage.py script field, enter the absolute path to the manage.py file in the Django project, e.g. /home/vagrant/PoeMogul/manage.py.
Click Apply and then OK to save the changes.
Now, when you run the Vagrant Django Server configuration in PyCharm, it should use the correct paths and start the Django development server on your Vagrant virtual machine, accessible at 0.0.0.0:8000 from your host machine.