PyCharm configure remote docker python interpreter for ROS - python

I have access to a Linux box with a ROS docker container. I develop from a separate computer so I've configured PyCharm to use the remote docker container as my python interpreter (via the "docker" option, not the "docker compose" option). While the connection to the interpreter is successful, ROS modules like rospy are not accessible (PyCharm complains that the module is not found).
I can import rospy just fine when I try it from inside the container (proving that it works), but PyCharm doesn't seem to recognize it. PYTHONPATH is correctly configured as well in the container, but the interpreter on PyCharm doesn't seem to be picking up on the ROS dist-packages.
How can I fix this?
Thank you!

Related

VSCODE how to debug python in conda environment in docker container in remote server

I start by enabling the docker container in the remote server, then I connect VSCODE to that server via SSH, and finally I attach VSCODE to the docker (docker extension installed).
I have selected the interpreter in the conda environment by editing a ./.vscode/launch.json file
When I start the python program debug the packages available in the conda environment are not visible to the python program.
What am I doing wrong?
thanks
You most likely need to select the Interpreter inside VSCode.
First open up the Command Palette Ctrl+Shift+P, then type Python: Select Interpreter then select the environment you want to use.

Setting local PyCharm remote interpreter in docker container on remote server

I have:
local PyCharm
remote server with docker container
I want run in my local PyCharm code (code on remote server) in remote docker container Python interpreter, for debug.
How to set it up?
I also found articles on the Internet, with the following description that I did not need:
local PyCharm -> ssh server interpreter
local PyCharm -> local docker
While it's not impossible to connect pycharm debugger with your remote docker container, it's much easier to use terminal interactive debugger - pdb. There are a lot of pdb flavours, if you don't like plain console
webpdb graphical debugger in a browser
pudb ncurses version, has some extra features like always listing your location in code and local variables.
I highly recommend checking them out. I use pdb on daily basis to debug python code in local docker container that has a complex run script.

Pycharm, Docker and GUI

So i have downloaded openAI gym into docker. And i am running Pycharm with docker remote interpreter. Everything works fine until the code gets to the rendering part where it crashes. I know that it is caused because Docker does not support GUI.
I tried using x11 but it didnt work.
Any advice ?
Assuming you're on OSX:
Your problem is probably not related with pycharm but more with how docker tries to connect to x11.
Make sure you installed the latest version of xQuartz and allow x11 network clients. Then mount the x11 socket as a volume mount in the docker container.
This blog post has a pretty good explanation on how to do that
https://fredrikaverpil.github.io/2016/07/31/docker-for-mac-and-gui-applications/

How to run a python script on a remote ec2 instance using sudo from pycharm

I am running pycharm 2017.2.3. I want to run my python script on a remote ec2 instance using sudo user through pycharm. How do I acieve this?
Follow the steps below:
Go to File -> Settings -> Project Interpreter and add a new interpreter
Click on + to add a new python interpreter and then click on SSH interpreter
Provide your EC2 Public DNS in HOST and ubuntu as username
Click Next and add the private_key.pem file.
See this article for more details:
PyCharm setup for AWS automatic deployment
It looks like you can configure your python interpreter over SSH with the professional version of PyCharm.
Configuring Remote Interpreter + PyCharm
Finally found an answer after a researching through the internet. We can have a script on remote machine as a pycharm interpreter. Create a following script on a remote machine and make sure the script is executable.
#!/bin/bash
sudo /usr/bin/python "$#"
Now change the project interpreter to point to the above script on remote machine in pycharm. Now every script you run on local machine gets executed on remote as a sudo user.

Not able to debug on docker container with PyCharm 5

I'm trying to debug a Django app with PyChar that I have in a Docker container. Originally I only had docker-engine and docker-compose installed, but looking at this post:
https://www.jetbrains.com/pycharm/help/configuring-remote-interpreters-via-docker.html
So I've proceeded to install docker-machine, I can see it working. But when creating the remote virtualenv in Python interpreter settings page, I see no machines in the dropdown.
I've specified my docker-machine executable to be at /usr/local/bin, that's where it is (by the way, Linux Mint 17 here).
Any idea what I'm missing here?
Thanks!

Categories