Connecting to remote interpreter when starting PyCharm - python

I have a remote interpreter set up in PyCharm.
Everytime I close and reopen PyCharm, the connection seems to be broken, and the process to "reopen" the connection doesn't feel efficient to me.
Before doing the following, it is not possible to run any script.
Here is what I usually do:
File -­> Settings
Project -> Project Interpreter
Click on the gear icon on the right.
Choose "More"
With my remote interpreter selected, click on "Edit"
Change "SSH Credentials" for "Deployment Configuration" (all the info is already filled)
Click "ok" multiple times to close everything up.
At that point, I can run any scripts on the remote machine.
What is the best/fastest way to do this? (any way to "save the settings"?)

Check option "Visible only for this project" of deployment configuration. This error occurs when the check mark is set.
https://www.jetbrains.com/help/pycharm/2018.3/deployment-connection-tab.html
if this checkbox is selected in an SFTP configuration, you cannot use
its SSH credentials for configuring a remote interpreter.

This was a bug in version 4.0.2 of PyCharm and was corrected in version 4.0.3.
Edit: No longer true. I tried with another computer and having the most recent version doesn't fix the problem.

i meet the same error, file->settings checking your interpreter setting,
You don't set the 'host' and 'post',or your set but the content was clear. check again, and it truly work

Related

Unable to run smallest windows service in Python

According to this answer I created a smallest Windows service in Python.
Then I ran successfully:
python.exe smallest_service.py install
and
python.exe smallest_service.py start
with error message
Starting service SmallestPythonService
Error starting service: The
service did not respond to the start or control request in a timely
fashion.
My Python version is Python 3.9.6
pip freeze
pypiwin32==223
pywin32 # file:///C:/Users/me/Downloads/pywin32-301-cp39-cp39-win_amd64.whl
How can I fix it?
Here are the list of scenarios one may see -> Error starting service: The service did not respond to the start or control request in a timely fashion.
Missing DLL file: Another instance of the error occurs when you have a missing DLL file on your computer which is used by numerous other applications as well. If this DLL file is in conflict or isn’t present at all, you will experience the error message.
Corrupt/missing system files: Another instance of why this issue occurs is because there are corrupt or missing system files on your computer. If the very installation of Windows is not proper and has issues, you will experience numerous problems including the error message under discussion.
Outdated Windows: Microsoft officially recognized this error message on their official website and even released a temporary hotfix to solve the problem. However, recently they removed the hotfix and instructed users to upgrade to the latest iteration of Windows.
Solutions
The very first thing which we should try is changing the timeout settings of your services through your registry editor. Whenever a service is requested to launch, a timer is started with a predefined value. If the service doesn’t start within this time frame, the error message comes forward reporting so. Here in this solution, we will navigate to your computer’s registry and change the value. If it isn’t present, we will create a new key for it.
-> Press Windows + R, type “regedit” in the dialogue box and press Enter.
Once in the registry editor, navigate to the following file path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
-> search for the key of ‘ServicesPipeTimeout’. If you find it already there, you can move to directly edit. However, if you don’t find the entry, select Control, right-click on any space present at the right side of the screen and select New > DWORD
-> Name the key as ‘ServicesPipeTimeout’ and set the value as 180000 (You can also right-click the value and click Modify if the option to set the value didn’t come in your case.
-> Save changes and exit. Restart your computer completely and then try launching the service. Check if the issue is resolved.
Solution 2: Getting Ownership of the Application
Another rare case that we came across was not having the ownership of the application caused the application not to execute the service properly. This makes sense as if the application doesn’t have enough elevated access, it will not be able to send/read the response to/from a service (especially if it is a system service). In this article, we will navigate to the executable of the application and then change the ownership to our username. If successful, this will solve the problem of getting the error 1053.
Bonus Tip
Making sure .NET Frameworks are in sync: If the application/service which you are trying to launch is on another Framework than that of the hosting machine, you will experience issues. Make sure that the frameworks are in sync.
If that doesn't work for you. It might be interesting to use NSSM. It is an easy piece of code that makes any py file into a windows service.
I've also found that most service creators only work with 32bit Python, so that might also be interesting to look at.

Pycharm CE not hitting breakpoints in my Django project

I have my project properly configured to run manage.py in the right place, with the right settings.
I also have debug breakpoints set in a method that I know with certainty is being executed (I've put a print statement there and it executed as expected). The breakpoints are not disabled or conditional:
When I hit the "Run in debug mode" button, using the above run configuration (I'm sure it's the same one because it's the only one I've configured for this project), this is the console output I get:
pydev debugger: process 38083 is connecting
Connected to pydev debugger (build 192.5728.105)
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
December 23, 2020 - 19:22:22
Django version 3.1.4, using settings 'FEArena.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
When I tried putting a breakpoint in manage.py, it worked as expected, triggering just when I hit the 'debug' button. However, after the app has started, when I use a REST client to trigger the above method, the one with breakpoints in it, the breakpoints do not trigger and the debugger doesn't start. I get a 200 OK response in my REST client, but PyCharm does not stop and execute the debugger at any point.
I looked at other answers that advised setting "Gevent compatible debugging" (which I don't have, because I'm using Community Edition), and I've tried deleting the .idea/ folder for the project, which also didn't fix the issue. I'm not sure what else could be causing this. I just want to debug my program.
My PyCharm version information is
PyCharm 2019.2 (Community Edition)
Build #PC-192.5728.105, built on July 23, 2019
Runtime version: 11.0.3+12-b304.10 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.7
GC: ParNew, ConcurrentMarkSweep
Memory: 4029M
Cores: 8
Registry:
Non-Bundled Plugins: com.karateca.jstoolbox, mobi.hsz.idea.latex, net.seesharpsoft.intellij.plugins.csv, nl.rubensten.texifyidea, org.intellij.plugins.markdown
What could be causing the breakpoints to not be triggered, and how do I fix this? I need breakpoints to debug other parts of my program.
Are you running your server in a console by any chance? If thats the case try stopping the server runing in console and restart the one in PyCharm
I was having a similar issue previously in PyCharm when I was invoking executor.submit. I had to insert a line requesting the results of the code in order to re-invoke the expected debugging behaviour. If your code is threaded, you may wish to start there.
future = executor.submit(control, channel) # spawn a function control(channel)
print(f'Future result is: {future.result()}') # new line I had to add to enable debugging
Edit: Adding the link to the thread that helped me with similar behaviour in PyCharm. concurrent.futures.ThreadPoolExecutor doesn't print errors
My current working configuration is on this :
It does not have any script path or parameters.
When I click on the "Debug" green button, the command automatically launched is :
/Users/.../virtualenv/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 55583 --file /Users/.../manage.py runserver 8000
What about yours ?
Hi I am writing this answer as I cannot comment because of my reputation no. By any chance, did you installed cython debugger toolkit that pycharm keeps on suggesting? If so, i have faced the same issue. The solution is to delete cython speedups somehow. You can follow this link to do that.
Basically you have to go to the directory called _pydevd_bundle and delete pydev*.so files. Now that requires root privilege. If you have that and you are able to delete them, then most likely it will work(provided you had installed cython debugger extension).

How do I get the codes still running on a remote host when I close JetBrain Pycharm?

I use JetBrain Pycharm to run codes on remote hosts. Because my codes need to run for a long time, I want to temporarily turn off JetBrain Pycharm and let the codes still run on the remote host. Untill the codes are executed, I opene pycharm to see the results on the remote host.
How do I get the codes still running on a remote host when I close JetBrain Pycharm? I guess that I should click the "Disconnect", but it does not work as I think.
First, I turn on Pycharm and let the codes run on a remote host.
Secondly, I want to temporarily turn off JetBrain Pycharm and let the codes still run on the remote host. I try to click on "Disconnect".
Thirdly, I turn on pycharm again to see if the code is still running. However, it may not work as I think.
So, How do I get the codes still running on a remote host when I close JetBrain Pycharm? Thank you very much!
Yes you should click on disconnet and it will not terminate it.

Remote debuging on Pycharm is concatenating local and remote path

I have a problem that I haven't been able to find an answer to.
I'm trying to debug a Python program running on a Raspberry Pi. The source code is located on my PC.
I set up an FTPS deployment and remote interpreter over ssh.
When I just run the app on the remote Raspberry Pi there are no problems.
The problem appears while I try to set up a breakpoint. In this case pydev writes:
>pydev debugger: warning: trying to add breakpoint to file that does not exist:
/home/pi/python/f:/python projects/server/server.py (will have no effect)
Pycharm thinks that the path to the app is the path on the remote computer + the path on the local computer.
Does anyone know what setting might be causing this and how to fix it?
From Run/Debug Configuration: Python section of PyCharm 3.4.0 Web Help:
Path mappings –
This field appears, if a remote interpreter has been
selected in the field Python interpreter. Click the browse button
to define the required mappings between the local and
remote paths. In the Edit Path Mappings dialog box, use add/delete
buttons to create new mappings, or delete the selected ones.
Configuring this option in your debug configuration should solve your problem.
Maybe it's obvious, but I was getting the same problem when using ~ instead of writing out the whole path of my home directory for the remote mapping.

NetBeans debugging of Python (GAE)

dev_appserver works normal when run it. But if i try o debug, i found an error caused by
__file__
that is changed on jpydaemon.py. Has anyone successfully debugged apps on NetBeans?
Nope but I'm interested in setting this up. You have to attach the netbeans debugger to the port somehow. This may help you: here's an example I was reading about for java: http://blogs.oracle.com/leonfan/entry/netbeans_development_series_for_google
Quoted what I found pertinent to your question dynback
"How to debug application for Google App Engine
Since we already map 'test' action to 'debug', we should right click on project and choose 'test' to do debug'. When system is running and listenning on Java remote debug port 5005, attach debugger under menu 'Debug':"
You need to make sure the port in your debug settings is not in use.
I am assuming you have the python plugin in stalled for Netbeans.
Go to your settings and select python and then the Debugger tab.
The debugger port is set there.
Check your in use ports (In Windows open a command prompt and run the NetStat command)
If the port configured in the debugger tab is in use then select a port that is not in use and try again.
The default port appears to be 29100 but when I first installed the python plugin that was not the setting I saw there.
When I changed it back to the default which was not in use it worked.
I hope that helps.

Categories