Vagrant, Pycharm and Django - setup for newbies

  • 15
  • 62

Hello,

I've lost a great deal of time for the last 4 days trying to get the thing to work.
So i'm asking can anybody please point me to a solid tutorial about pycharm/vagrant/django setup. The quick tutorials tackle the issues separately, and i'm not interested in running a simple script through an SSH, i want a full django environment, with latest python and django distribution on a vagrant VM.
U'm also really frustrated with the lack of information when i press the run button. Nothing seems to happen, no output whatsoever.
For the last 4 days i made my own vagrant file, i customized the chef cookbook, I played with every possible combination of debug settings, i created a virtualenv on vm, I press the run button and absolutely nothing happens.

I can put some screenshots here if you want, but it would be really great if there was a nice step by step tutorial of setting up all of this.
And i'm a huge fan of your work as a company, love Resharper and Pycharm looks really cool.

Cheers!
<message deleted>

Hi Dmitry,

The screen cast is great, but it really doesn't answer the question about
setting up the environment. I see that some people are using it the way i
want to, but i don't see any resources about it


On Wed, Apr 3, 2013 at 4:04 PM, Dmitry Filippov - PyCharm <
jetforum@jetbrains.com> wrote:

* PyCharm <http://forum.jetbrains.com/forum/PyCharm> * > * Vagrant,
Pycharm and Django - setup for newbies<http://forum.jetbrains.com/thread/PyCharm-1420>
* [ * django <http://forum.jetbrains.com/tag/PyCharm-django> * + * vagrant<http://forum.jetbrains.com/tag/PyCharm-vagrant>
* ] 10:04 am<http://forum.jetbrains.com/thread/PyCharm-1420?message=PyCharm-1420-1> Dmitry
Filippov <http://forum.jetbrains.com/user/Dmitry.Filippov@jetbrains.com>

Hi Bruno,

We have screen cast for Django development with PyCharm:
http://tv.jetbrains.net/videocontent/django-development-with-pycharm


Dmitry Filippov
Product Marketing Manager
Jetbrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Bruno Samardžić <http://forum.jetbrains.com/user/brunoAltinet> @ 9:53 am<http://forum.jetbrains.com/thread/PyCharm-1420>

Hello,

I've lost a great deal of time for the last 4 days trying to get the thing
to work.
So i'm asking can anybody please point me to a solid tutorial about
pycharm/vagrant/django setup. The quick tutorials tackle the issues
separately, and i'm not interested in running a simple script through an
SSH, i want a full django environment, with latest python and django
distribution on a vagrant VM.
U'm also really frustrated with the lack of information when i press the
run button. Nothing seems to happen, no output whatsoever.
For the last 4 days i made my own vagrant file, i customized the chef
cookbook, I played with every possible combination of debug settings, i
created a virtualenv on vm, I press the run button and absolutely nothing
happens.

I can put some screenshots here if you want, but it would be really great
if there was a nice step by step tutorial of setting up all of this.
And i'm a huge fan of your work as a company, love Resharper and Pycharm
looks really cool.

Cheers!

JetBrains Forum | Build #143 (Nov/16/2012 5:22PM) | Feedback<http://confluence.jetbrains.net/display/JETF/Feedback>

Hi Bruno!

thank you for your queries.
So here we have several tutorials/screencasts you may be interested in:
Django development with PyCharm:
http://tv.jetbrains.net/videocontent/django-development-with-pycharm
almost the same, but in textual form:
http://www.jetbrains.com/pycharm/quickstart/django_guide.html
and Vagrant/SSH specific tutorial:
http://www.jetbrains.com/pycharm/quickstart/configuring_for_vm.html

probably that's all we have at the moment.

About environment setup on vm: http://www.jetbrains.com/pycharm/quickstart/configuring_for_vm.html -this one should suffice.
Basically we have notion of "remote interpreter". So once you will configure it with your vagrant box: http://www.jetbrains.com/pycharm/quickstart/configuring_interpreter.html

the rest is the same as for local interpreters.

And at this point you can use
http://tv.jetbrains.net/videocontent/django-development-with-pycharm

Unfortunately we don't have dedicated tutorial with mix of django and vagrant usage.
Thank you for asking that. I definitely will trigger creation of such a tutorial.

By the way, i'm curious why, when you pressing run button nothing happens...
Could you provide screen shots of what happens after pressing run button?


Dmitry Filippov
Product Marketing Manager
Jetbrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Thanks again Dmitry, i went through those tutorials but there are a lot of questions unanswered there:
1. how to set up debugging settings for django
2. best practices for placing files and projects on vagrant
3. should i have a vagrant per project or 1 vagrant for all projects
4. using specific python version on my vagrant machine
5. setting up VagrantFile properly, and so on and so on...

Honestly, the only thing i would really need is a project i can download that works so i can play around with it. The information on the net is terribly scattered and hard to make sense of for a newcomer. But i love the concept, i think it's definitely really worth the trouble even for you guys. With a proper VagrantFile and a VM you would single handedly kill a ton of environment specific issues.

Bruno, great feedback!
you are right, questions mentioned are not covered in these tutorials, but should be... I am going to put it into development.

However, lets solve your particular problem first, so maybe we will get more exact picture on what we are missing in tutorials.

Could you describe what have you done already step by step? Set up vagrant environment, configuring remote interpreter on vagrant box, create Django project with default interpreter = remote interpreter on vagrant box?

It is weird that on run button you get nothing... Probably some bug? lets figure out!
Dmitry Filippov
Product Marketing Manager
Jetbrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I added vagrant, configured it, set up a venv and set it as my project interpreter.
But something fishy is going on there, it shows me unresolved reference errors
Capture3.JPG


I can start the project in vagrant through console

Capture2.JPG


My settings in debug config are following (i tried all sorts of combinations).

Capture.JPG


and my interpreter settings are following



Capture4.JPG


When i press run the button goes gray (pressed) for a second or 2, and then nothing. I don't see any output whatsoever

Hope this is enough info.

The vm is lucid32, and my operating system is windows 8

Hi Bruno, which interpreter is selected as a project default (Settings | Project Intepreter -> combobox Project Interpreter) ? What result do you get running/debugging the run-configuration on the screenshot?

the default is the one that works on the remote. As for when i press run/debug, nothing really happens, the button looks pressed for a second or 2 and then nothing (see screenshot below). These messages about skeletons come up when i switch between interpreters, maybe that's some kind of problem? I wish i could see some output when running. I would like to be able to run it atleast:)
image1

Could you please attach logs (you can locate it with Help | Show Log in Explorer)

from what i gathered in the stack trace, there's a problem with my vagrantfile, so here it goes:)

Vagrantfile (5.3KB)

Thanks,there was a bug, here is an issue for that: http://youtrack.jetbrains.com/issue/PY-9442
The fix will be available in PyCharm 2.7.2, that should be available this week.

here's a picture of default interpreter
image1

oh, and when i start it manually in the terminal, i can access the site from my workstation just fine

Hi guys, i made a blog post about setting up vagrant, django and windows. I'm pretty happy with results, though it was a bit of a manual work. There are also 2 issues I ran across which could pose a problem for windows users. They are documented in the post.
Hope you like it!
http://www.run80.net/?p=257

Bruno,

great! it is nice and comprehensive... But... I'm just curious... Why you did all your setup manually? I mean virtualenv, django... and such "django-admin.py startproject DjangoTest /vagrant"... hmm... It seems like you are not getting the most out of PyCharm((( Did you know that PyCharm can install Django and create virtualenv for you in couple clicks? And you can run/debug django projects from PyCharm as well...
Dmitry Filippov
Product Marketing Manager
Jetbrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Well i encountered one chicken-egg problem. When i would start pycharm and wanted to create new project, it would ask me to select an interpreter, but since i don't have anything installed locally i couldn't select any interpreter at all. You can only define a vagrantfile and consequently remote interpreter once you open a directory or create a project. So i had to open a directory, create vagrant and then convert directory to django project (didn't know how to do the conversion through pycharm). I would put that in but i missed it. So that's why I went this route.
But i don't actually mind this aproach, i'm not yet totally into python development but i like the fact that anyone can pull my project and set up a vagrant enviroment with running just one script after "up".

I would also like to steer your attention to the 2 issues I encountered (i'm not sure if it's a vagrant bug or a pycharm bug):
1. For some reason name of the machine in the generated vagrantfile contains “(virtualbox)” sufix, open up VagrantFile and delete that before uping vagrant. the line should be config.vm.box = “lucid32″ after correction.
2. After “fill from vagrant config” step you will probably get “Private key not found” exception. Download a PuttyGen tool from following link: http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe
start it File->”load Key” and select the key c/users/you/.vagrant.d/insecure_private_key (have All files filter selected)
Then go file->save private key, and save it in the location you prefer. Then point to it in the pycharm vagrant dialog box instead of that unsecured_private_key.

I believe there's a lot of room for progress and untapped power in the pycharm-vagrant combination. There's still an issue of destroying the database data when destroying the vagrant (i haven't found good resources about that issue on the net), having multiple projects using one vagrant, maybe even one project using multiple vagrants (but that would be an overkill for me:).
But i really love the fact that i'm using a familiar tools and GUI for developing, and testing and debugging on Linux. Makes it real easy to follow all those python tutorials:).