Support for working inside VM??

My company's workflow doesn't seem to fit well to many of these IDEs. I've played with PyCharm for a bit and I really like it so here's hoping that I'm simply not understanding how to do this...

We're developing large-scale applications that run on hosted Linux servers. For a variety of reasons, we work with Virtual Machines both in the cloud and locally on our PCs and Macs so that we have a mirror of our deployment environments to work with.

When developing, we will run a VM on our PC or Mac and run the entire stack of application server (Python), database engine, web server, etc. To edit the Python source code, we mount the source code directory on the VM as a Samba mount and typically use lower-tech text editors (such as TextMate) to edit the source files, then switch to an ssh session to restart services, work with the VCS, etc.

While I can mount the share to the source code and edit it inside of PyCharm...very little actually works. PyCharm is of course unable to resolve any imports, etc. because the Python interpreter is actually in a virtualenv on the Linux VM and I can't add that interpreter to the list through settings without getting an error (because, I'm assuming, it's a Linux executable and not a native to the OS executable where PyCharm is running).

Is there some setting=magic that I'm missing or is this just not going to work?

0
8 comments

Hello Rob,

The recommended approach in this case is to set up a copy of the environment

(Python interpreter and the necessary libraries) on your main development

machine. It doesn't need to be able to actually run things (so you don't

need to install a database server for example), but at least the libraries

should be available for PyCharm to introspect and provide code completion.

For running things, most likely you'll have to keep using the ssh session

and won't be able to use PyCharm's run configurations.

My company's workflow doesn't seem to fit well to many of these IDEs.

I've played with PyCharm for a bit and I really like it so here's

hoping that I'm simply not understanding how to do this...

We're developing large-scale applications that run on hosted Linux

servers. For a variety of reasons, we work with Virtual Machines both

in the cloud and locally on our PCs and Macs so that we have a mirror

of our deployment environments to work with.

When developing, we will run a VM on our PC or Mac and run the entire

stack of application server (Python), database engine, web server,

etc. To edit the Python source code, we mount the source code

directory on the VM as a Samba mount and typically use lower-tech text

editors (such as TextMate) to edit the source files, then switch to an

ssh session to restart services, work with the VCS, etc.

While I can mount the share to the source code and edit it inside of

PyCharm...very little actually works. PyCharm is of course unable to

resolve any imports, etc. because the Python interpreter is actually

in a virtualenv on the Linux VM and I can't add that interpreter to

the list through settings without getting an error (because, I'm

assuming, it's a Linux executable and not a native to the OS

executable where PyCharm is running).

Is there some setting=magic that I'm missing or is this just not going

to work?

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Hmm, OK I suppose that could work. I guess I didn't expect to be able to run it per se, but what about debugging it? The Python code is a WSGI app running under Apache on the VM....is there any hope of an interactive debug session?

0

Hello Rob,

There is. You would need to copy PyCharm's debug runtime to the VM and use

the remote debug configuration to connect to the process running in the VM.

See http://blogs.jetbrains.com/pycharm/2010/12/python-remote-debug-with-pycharm/

for more information on setting up the remote debugging.

Hmm, OK I suppose that could work. I guess I didn't expect to be able

to run it per se, but what about debugging it? The Python code is a

WSGI app running under Apache on the VM....is there any hope of an

interactive debug session?

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Does this also work for running tests?

Also, is there a way to avoid having to copy everything? I have the local VM mounted as a drive on Windows via ExpanDrive and the access is instant, so copying the entire virtualenv would seem a bit redundant. Also, because my actual OS is different from the VM's OS, I can't install all dependencies locally so PyCharm would have to use the virtualenv's packages instead.

0

Hello Alan,

Does this also work for running tests?

Right now it's not possible to run tests on a remote machine and have results

displayed in PyCharm's graphical tests runner.

Also, is there a way to avoid having to copy everything? I have the

local VM mounted as a drive on Windows via ExpanDrive and the access

is instant, so copying the entire virtualenv would seem a bit

redundant. Also, because my actual OS is different from the VM's OS, I

can't install all dependencies locally so PyCharm would have to use

the virtualenv's packages instead.

One possiblity is to point PyCharm to a local Python interpreter and add

the paths to the packages installed under the VM's virtualenv to the list

of paths under Settings | Python Interpreters. This requires a bit of manual

work, but once everything is configured it should work just fine as long

as the packages are pure Python and do not contain any compiled modules.

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Not sure, I haven't tried that.

I did do as suggested and that mostly worked. The remote debug though doesn't seem to work for me...I can get it to connect to the debug server but then nothing happens.

0

That's a bit disappointing. Does that mean that I can't use PyCharm's code intelligence at all if I use natively compiled python modules that I can't install in the OS I'm using?

I thought PyCharm can work with remote Python virtualenvs without having to install the libraries locally?

There doesn't seem to be a good IDE with full support for working with code inside a VM, which I think is a pitty now that VMs are becoming more and more popular and many developers install them locally as part of their development environment. It would be awesome if PyCharm could take the lead in this one (I think the remote debugging -- if it works the way I think it does -- already puts PyCharm ahead of its major competitors, actually).

0

Hello Alan,

That's a bit disappointing. Does that mean that I can't use PyCharm's

code intelligence at all if I use natively compiled python modules

that I can't install in the OS I'm using?

In principle you can manually run PyCharm's skeleton generator scripts on

your target machine and then copy the generated skeletons to your local machine,

but we don't currently have a documented process for doing that.

I thought PyCharm can work with remote Python virtualenvs without

having to install the libraries locally?

There is nothing magical about a virtualenv; it's just a directory with a

bunch of Python libraries and a script to configure Python's sys.path to

use the libraries from the directory. For PyCharm's code analysis to work,

it needs to have access over a filesystem to the source files of the libraries

you're using.

There doesn't seem to be a good IDE with full support for working with

code inside a VM, which I think is a pitty now that VMs are becoming

more and more popular and many developers install them locally as part

of their development environment. It would be awesome if PyCharm could

take the lead in this one (I think the remote debugging -- if it works

the way I think it does -- already puts PyCharm ahead of its major

competitors, actually).

PyCharm isn't doing anything particularly innovative in terms of remote debugging

at the moment. Our approach is exactly the same as PyDev's, and I think both

Komodo and Wing do pretty much similar things.

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Please sign in to leave a comment.