Unable to run pylinter, set python interpreter in VS Code - python

I've seen a few questions opened on Stack Overflow and the dedicated VS Code Git, but all of the solutions have revolved on reinstallations and after trying this on the Python extension and VS Code itself multiple times with necessary restarts I'm still nowhere nearer to a solution. Linter was performing fine up until a few days ago when it seems to have broken out of nowhere.
I've also noticed that "Go to Definition" isn't working (either the hotkey or menu navigation), so not sure if it's more a VS Code issue or issue with Python implementation, Intellisense seems to be working fine so leaning towards the latter.
Steps to Reproduce
1) Cntrl + Shift + P to open command pallette
2a) "Python: Select Interpreter" - error "spawn EPERM")
2b) "Python: Select Linter" - error "command 'python.setLinter' not found"
Versions
Python 3.6.6
Visual Studio Code 1.28
Python extension 2018.9.0
Windows 10
User Settings
Tried setting an explicit path per suggestion, but again no dice.
{
"python.pythonPath": "C:/Users/saun89/AppData/Local/Programs/Python/Python36/python.exe",
"python.linting.pylintPath": "C:/Users/saun89/AppData/Local/Programs/Python/Python36/lib/site-packages/pylint",
}
I'll probably go ahead and open a ticket on the actual github (although this seems less a product issue and more an issue particular to myself), but wanted to check with the stack community to see if anyone else has had to troubleshoot something similar. At least until this gets inevitably voted down to oblivion being similar to some other existing questions.
Extensive Error log (from developer tools)
Just in case they're helpful
notificationsAlerts.ts:40 Error: command 'python.setLinter' not found
at t._tryExecuteCommand (commandService.ts:57)
at commandService.ts:50
at n.Class.derive._oncancel.then (winjs.base.js:1587)
at t.executeCommand (commandService.ts:50)
at t.run (actions.ts:220)
at t.run (actions.ts:268)
at commandsHandler.ts:309

in case you happen upon this question I did discover an answer here. Looks like the SPAWN EPERM error was in fact related to my running as a user rather than as an administrator. When I run VS Code as Administrator able to work with the command palette fine. Hope this helps someone!

You might also get this error when trying to use the search bar called spawn EPERM and the cause might be an antivirus.
since Visual Studio Code creates new process for search and other features (SPAWN corresponds to a new process creation) this can cause the Antivirus to stop that process and causing this error and the feature to no work.
solution: Create an exception in you antivirus for VS Code or disable the antivirus all together (if you feel like catching a virus)

For setting the python interpreter question, temporary solution that worked for me on my Windows and Mac machines: use relative paths.
So in my case, instead of absolute path;
"python.pythonPath": "/Users/userid/p3env/bin/python" (on Mac)
"python.pythonPath": "C:/Users/userid/p3env/bin/python" (on Windows)
I used relative path from my working folder;
"python.pythonPath": "../../../../p3env/bin/python"
I haven't got any problem on my Ubuntu machine though. This issue affects many people I believe. It is also discussed in a few issues: [3326], [3326]. It seems that it goes away in some update and comes back again in another somehow. Above workaround solution is not a very convenient way to do it so I hope there will be a permanent fix for this.

Related

How does a good python debugging workflow look like?

My latest python debugging workflow appears extremely slow to me, and little satifying. How can I improve?
Setting: I work with some third-party python packages from github.
Workflow:
run into error after entering some command to the terminal (Ubuntu WSL, python 3.7)
read terminal error message output, most likely the first or last one is helpful
from the last message i take the code reference (ctrl+left mouse in vscode) and look at the code
i find some function call in the third party module that looks very unrelated to the problem
i add import pdb to the module, and a pdb.set_trace() before that function call
i run the program again, and it stops at the breakpoint
using n,r,u,d i try to navigate closer to the source of the error
i eventually find some error raise condition in some other module, where some property of a certain variable is checked. the variable itself is defined some levels up in the stack
re-running the program and stopping at the same breakpoint as before, i try to navigate to the point where the variable is set. I don't know on which level of the stack it is set, so i miss it sometimes. I set intermediate breakpoints to save me some work when re-running
i finally find the actual cause of the error. I can check out the workspace and eventually fix the error.
i go through all the modules and remove the import pdb and the pdb.set_trace
Thanks for any suggestions
are you using an IDE, not fully clear in your question?
they tend to have graphic ways of setting breakpoints and stepping,
and it saves the hassle of changing the source.
not going into ide opinions, but examples of ide's with debuggers are spyder, thonny and others.
you can also run the debugger via commandline to avoid changing source, but I don't think that's the way to go if you are looking to simplify the cognotive load.
Yes these things you have to do and in extra you can do include logging everywhere as applicable to get exact point where it got occurred.

Autocompletion in PyCharm not working. I've made sure the intepreter is pointed to my project and I've tried invalidating caches

I remember autocompletion to be working for me on PyCharm some time ago, but I just noticed that is no longer is. It doesn't work for basic python syntax as well as any libraries.
I've tried using the "Invalidate Caches and Restart" option in the File menu of PyCharm. I've also made sure that the Project Interpreter is using the Python in the venv of the project created by PyCharm. I've tried a handful of other things but these two are the most common solutions I've encountered and nothing is working. Note that hitting Ctr-Space anywhere just gives me a "No suggestions" message (not sure if this is relevant but thought I'd mention it).
Any ideas? Any help or ideas at all are appreciated.

pycharm will not allow me to use my python on an Ubuntu operating system

I have been working on getting pycharm to use python easy right.. wrong, when I try to add python 3.5 the gui, keeps going back to no SDK at all and it won't let me add one. to better explain the problem I made this video to help. what I am doing should work but it is not. note this is on an Ubuntu operating system.
https://www.youtube.com/watch?v=g5dy1jlIHCs
It seems weird beucase JetBrains' product detects local SDK first without pain, but you have really problem with that.
Anyway, I think, we can solve the problem.
Try to look PyCharm log. You may see interesting things over there.
Delete VirtualEnv and use /usr/bin/python3.5. (Maybe, it can solve)
Check JetBrains owner (chown), read and write permissions (chmod). Also, check .idea file
NOTE:
This invalid VCS doesn't effect your usage of SDK because JetBrains has to read .idea to find your VCS settings (or other things)
Thank you
You have two interpreters with the same name, not sure how it happened but PyCharm doesn't allow it
remove one, also you select an interpreter for a wrong project (you have multiple opened)

Python3/MacOSX integration into pycharm

I have had trouble setting up the pycharm ide on my macosx10.7 with python3..
I have scoured every resource available and tried hundreds of approaches, at this point I must accept my incompetence and seek help via this channel.
In my research, I notice a lack of ground-up explanations on python integration into macosx and how to configure pycharm to import modules, run code within the editor, etc. If i ever solve this I will make a very detailed tutorial.
I have imported python3 successfully, it looks like it is linked appropriately from /sys/lib/frameworks to /usr/lib ...etc -- version control is working just fine.
I think my issue is either in setting environmental variables (tried the program to fix this and tried macports) and in the script needed to execute. it will catch errors throughout but final product does not run in python and returns printout of :
/Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2 /Users/anon/Desktop/pythonpractice/Py_Ex/classes.py
Process finished with exit code 0
i really need to get this configuration sound for my python programming class. please help (I've been through every line of pycharm website) .. preferably is there a way to map it via terminal? thanks for anyone who took the time to read this.
Summary of the discussion above:
Python 3.2.2 installation was broken on this Mac, installing ActiveState Python 3.2.2 from scratch and configuring it in PyCharm has fixed the problem.
Python path to be used in PyCharm settings: /Library/Frameworks/Python.framework/Versions/3.2/bin/python3
Incompatible third-party plug-ins may break PyCharm, uninstall/disable them in Preferences | Plugins.
Ensure the latest PyCharm version is installed.
User's code depends on the graphics.py module which was not in the project or in the PYTHONPATH. Putting it into the project has solved the problem.
Most likely the wrong Run/Debug configuration was used in PyCharm, the easiest way to run or debug such scripts is by using the editor context menu Run and Debug actions. PyCharm creates the configuration automatically and debugging works fine as shown of the screenshot:
If one wants to configure and debug it, he can use the code.zip file to get started.
Sorry for the comments mess above, but it was not possible to move it into chat as user had only 1 reputation point, hence not able to use the chat feature of StackOverflow.

Java SDK Update Tool "Python runtime could not be found"

I'm brand new to java, trying to dive into Java EE and I'm following the instructions here: http://docs.oracle.com/javaee/6/tutorial/doc/gexaj.html#gexaa to try to get everything setup. Unfortunately I'm not able to run the java update tool because I get the error:
Update Tool was unable to start.
The Python runtime could not be found.
To fix this problem use the UC_IMAGE_PATH environment variable to provide a path to a valid image.
To be clear, I've installed Netbeans at the Java EE 6 SDK and that's as much as I know. I have a background in PHP so this is a little different.
What piece am I missing?
check this solution:
http://www.java.net/forum/topic/glassfish/glassfish/update-tool-error
You can also start galssfish server (from NB or .bat file), log into administrator console (web browser: localhost:4848 if You haven't changed default ports) and then run update tool. Works for me, even though the first solution doesn't.
(I know, it's been a year of waiting for the answer, but someone might need this ;) )

Categories