Pycharm debugger: breakpoint links to remote_source files - python

While using the pycharm debugger breakpoints are linking to copies of files saved in remote_sources,
C:\Users\me\.PyCharm2019.2\system\remote_sources\921495913\41753927\pipeline.py
rather than reading the correct project file. C:\Users\me\project\pipeline.py.
The problem occurred after I had updated some python packages (pandas, pytest). Not sure if it is related.
I have my root set to C:\Users\me\project\ and WSL mapping C:\Users\me\project\ to /mnt/c/Users/me/project. These have not changed and have been working fine in the past.
I am using Pycharm professional 2019.2, Windows 10 running Ubuntu with WSL and have WSL remote interpreter configured in Pycharm.
How can I remove the link to \.PyCharm2019.2\system\remote_sources\ and debug on local files as I always have in the past?

Related

How do I activate a VSCode environment from ssh?

I am currently using VS Code on a server (through SSH). Everything works fine, and I installed Python packages and work with Python notebooks.
Now, I want to login to the server (not a problem) and run the Python code I created on VSCode, rather than executing it remotely.
My main issue is that I am not sure how to activate the Python environment (if there is one) that VSCode server's run so that the code can execute.
Is that possible?
I see I have a .vscode directory in my home directory, and there are package installation there.
After connecting vscode remotely, you can use it as a regular vscode, which is no different from running Python files locally:
install python
install pylance extension
choose correct interpreter
edit your code and run the python file.

VSCode python not finding relitive files in Windows Subsystem for Linux

I'm following the Practical Python Programming course from David Beazley. Having recently switched machines (Ubuntu to Windows 10...i know...) I'm picking this back up.
Environment: Visual Studio Code, using Windows Subsystem for Linux (WSL) running Ubuntu, all the necessary VSCode extentions applied to work with WSL.
Context: python allows you to reference files with code like the below (adapted from the course linked to above). In this case my python module is in a parent directory called Work, and within it there is a directory called Data that has various files in it.
read_data('Data/portfolio.csv', 'Data/prices.csv')
With WSL, you can launch VSCode by doing code . and hitting enter in a Windows Terminal once you are in the directory with a file you want to edit. In my case, doing so in my Work directory (on Ubuntu WSL) starts VSCode and I can run a python file, and as I would expect, I can find the files in the Data/ directory (to be clear, the read_data(... function works).
Issue: if I come into WSL via the Windows GIU first (i.e. clicking the shortcut on my Windows 10 desktop), navigate to the folder on WSL with my code, and run the same file...I get python errors to say it can't find the files I'm referencing. My fix is to reference the full file path.
Why would this be? I've noticed if I do a print Path.cwd() using pathlib while running the file as described above in "Issue" then the working directory is my Ubuntu home, not the directory where the code is.
Is there an interpreter setting or config in VSCode I'm missing?

No menu for adding WSL python interpreter in PyCharm

I was following this guide from official jetbrains page, until the step 2 comes in the existence.
In the picture mentioned in that page, has so many options like ssh, wsl, vagrant, docker, etc. In my pycharm (latest 2019.3.4) it only shows 4 options - venv, conda, pipenv and system-interpreter.
There is no WSL menu in the add python interpreter dialog.
See the below image:
Searched web for an hour and found no results that show how to fix it. I started plugin search in the PyCharm if there's an external plugin to do so, but there were no plugin named as WSL.
I don't know how to setup the WSL interpreter, I have python3.8 installed on my wsl right now.
Any help will be appreciated!
I have solved this by
Uninstalling pycharm with history and cache.
Removing folders completely from C:\Users\%USERNAME%\AppData\Local and C:\Users\%USERNAME%\AppData\Roaming\JetBrains and
Clean re-install of pycharm
WSL interpreter option shows up as normal
Ideavim is creating a conflict I guess.
This helped me without having to reinstall PyCharm. In PyCharm go to
File, Manage IDE Settings, Restore Default Settings.
I think PyCharm was unable to find my WSL after I updated my WSL's Ubuntu 20.04 to Ubuntu 22.04 and changed the name. (Maybe this issue wouldn't have come up if I had kept the name "Ubuntu-20.04".)

Autocomplete Pycharm Pro 2017.1

Dev. Box: Windows 7
Remote Box where project should be deployed: Redhat Linux
Project on remote machine does not utilise pip or virtualenv but rather an in house alternative to virtualenv.
I setup my remote interpreter in Pycharm via Ssh to the python interpreter in linux box and see all the modules on remote with version info listed.
Pycharm tries initially to upload Pycharm helpers to remote box but is I guess unable to install them as I imagine it cannot find usual python tools like pip, so I see a banner on the remote interpreter saying Setup tools not present on remote. Regardless when this preference window is closed pycharm initiates indexing I assume the remote interpreter and modules.
When I open a file in the code however after indexing completes I cannot get auto code complete to work for any module even standard library modules i.e. json, sys, os...
I tried to get more info on Pycharm Helpers that try to get installed but all I found was they get used for remote debugging and "scaffolding" which I can't find additional details as to what the latter means or if it is even relevant to get autocomplete to function.
Need help really badly on this, thanks in advance to anyone who can aide me in this matter.
Some collegues got around this by having Devbox be a Mac OS or any other linux distribution, cloning the project locally and then using the local interpreter option in Pycharm but unfortunately I can't utilise local interpreter even though the project is cloned because on windows Pycharm expects the local interpreter to be a .exe

IntelliJ + Python plugin: Python remote interpreter gets created without classpath, does not work

When I create a new remote Python interpreter, IntelliJ doesn't find any dependencies to my code and doesn't seem to index any libraries. Most of the code is red. I think I've pinpointed that to the "classpath" being completely empty, which is unlike some other Python SDKs that I have added (local ones). Some of the times I am able to get it to populate the classpath with paths pointing to the IntelliJ Caches directory by clicking around in the interface, but I most of the times it does not work and I cannot reproduce how to make it work. How do I make sure the classpath gets populated correctly?
I am using IntelliJ Ultimate version 2016.2.1. with the Python plugin version 2016.2.162.43. I am developing on a Vagrant virtual machine and I'm adding a Python remote interpreter that is inside a virtual environment (venv) inside the virtual machine. When I add the remote interpreter, I use:
On the SDKs tab - the + button.
Python SDK
Add Remote
I select the Vagrant option
Point it to my Vagrant project directory.
Point it to the python3.5 executable inside my virtualenv
Add the SDK
Then the classpath looks like this: https://www.dropbox.com/s/3xbzopb4y9bhn0u/Screenshot%202016-08-11%2017.19.43.png?dl=0 and IntelliJ doesn't recognize any libraries/builtins. For other SDKs, the classpath contains several entries with remote_sources, python_stubs or python-skeletons in the name and they work.
As a workaround, I copied every entry from the local python interpreter classpath to the remote one and everything seems to work
Edit:
Actually, I don't know what triggered it, but some days after I wrote this, I noticed that IDEA started downloading source files from the server. I went to the interpreter settings, and the classpath entries I had manually added were gone and replaced by "system/remote_resources" entries. I think this is how it's supposed to work, but unfortunately I don't why I didn't work from the start nor how to trigger the correct behavior, it just started working on its own.
While this issue is a bit older, I had the same issue today with IntelliJ IDEA 2021.2.
I was able to solve this by using Navigate -> Search Everywhere -> Type interpreter -> Select Rescan Available Python Modules and Packages.
This prompted downloading of the remote resources and indexing. Afterwards, the classpaths were filled in properly.

Categories