I'm using the Redhawk IDE. I noticed when I write Python in the IDE, none of the built-ins (len(),str(),True,False,etc...) are recognized, which gives errors and causes them to be underlined in red.
However, if I install to Target SDR anyway, the component seems to function normally.
How can I get Python in the IDE to recognize built-ins so I can get rid of the faulty errors?
Erik's answer led to the solution. What worked for me is:
Window -> Preferences
PyDev -> Interpreter - Python
Remove Python interpreter
Click "New..."
Enter interpreter name ("Python" works) and select path to interpreter
By default, the top option was selected. Make sure it isn't:
Click "OK"
Click "Apply"
You should now see that the built-in functions are recognized by Python.
If you can't run any Python in the IDE, there are two possible explanations:
1. You have an incorrect Python path being set for you by Eclipse, and you will have to adjust it manually. Using this article from Opal, you can easily check that Python is in fact correctly linking to your IDE, and if it isn't you can point it in the right direction.
2. You have a broken installation of Redhawk. Sounds dubious but you can always try a fresh install.
Related
The question is: How to apply PyCharm inspection quick-fixes in bulk? [Presumably the same features are also in IntelliJ, CLion, et al.]
I'm porting a Python 2.7 code base to Python 3.8 and want to make one kind of change at a time [e.g. replace raise Exception, "message" with raise Exception("message")], review it, and test it. Eventually I'll try using python-modernize, but can PyCharm make specific types of compatibility fixes in bulk?
You can configure PyCharm's Code compatibility inspection to check for, say, Python 2.7 + 3.7 + and 3.8, then run that inspection on your entire project or a smaller scope. Or use the Code > Run Inspection by Name... menu command to run the Code compatibility inspection with a temporary choice of options and scope. The warnings will list items like these:
Python version 3.7, 3.8 do not support this syntax
Python version 3.7, 3.8 do not have module __builtin__
Python version 3.7, 3.8 do not have method xrange
Python version 3.7, 3.8 do not have module cPickle
dict.iterkeys(), dict.iteritems() and dict.itervalues() methods are not available in py3
basestring type is not available in py3
If you select an example of these first two types of warnings, PyCharm can apply a "quick-fix" like Convert raise statement to supported form. For the other warnings listed above, it can only offer to suppress the warning :-(
I have hundreds of these! How to fix them in bulk?
There's a cute trick.
In the Inspection Results tool window, click the Expand All button (or type Command-+ or whatever the equivalent is in your keymap).
Type Command-F (or the equivalent) to Find an example of your chosen type of inspection warning, e.g. search for syntax.
(PyCharm won't open a "Find" dialog for this but you can still type the search text and it will display that in an overlay.)
Do Edit > Select All (or type Command-A or equivalent).
Now click the button to apply the quick-fix!
(If you know how to make PyCharm fix the other compatibility warnings, please add more Answers. Otherwise, it's on to modernize.)
There is Hide/Show console option in "View" menu of Sublime Text 3. I tried shell, Python and Ruby commands in it but it always returns an error.
What is this console used for?
The Unofficial Documentation (which I prefer to the official documentation) states in the "Basic Concepts" section:
Sublime Text exposes its internals via an Application Programming Interface (API) that programmers can interact with using the Python programming language.
It uses an internal Python interpreter which is not the one in your system's PYTHONPATH variable. So, basic Python commands should be possible for you as it is working for me. The console output is:
...
skipping some console output before
...
plugins-loaded
>>> x = 1
>>> y = 2
>>> f = x * y
>>> print(f)
2
The purpose of the console is to interact with an API to control Sublime Text 3 internal settings:
>>> sublime.version()
'3211'
or:
>>> sublime.message_dialog("test")
which opens a clickable dialog with the text "test".
See the API reference for more information.
The console in Sublime is a window into the internal workings of Sublime in order to see the state of plugins and interact with the plugin host; the most important distinction to make is that the Sublime console IS NOT a Terminal; if you want access to arbitrary commands, you need to install a package such as Terminus to achieve that.
Most of the functionality in Sublime (including default functionality out of the box) is defined in Python plugins, and third party packages can also define Python plugins as well. The console is a window into that Python environment; if a plugin fails (like if the code is broken in some fashion), then the error that the code is generating ends up in the console.
Sublime also displays its own status into the console as well; the console contains output that indicates when plugins are being loaded and unloaded, how long it took Sublime to start up, what version you're running, etc. Any time you see an error dialog pop up, there's also a message added to the console (and in some cases errors go only to the console without being visible elsewhere).
Besides the major distinction that the console isn't a Terminal, it's also important to note that although you can enter arbitrary Python into the console and have it run, it's not meant to be your gateway to running a Python program (unless you want to evaluate single expressions and the like).
Many people fall into the trap of thinking that because Sublime uses Python for plugins that you can also use that environment to run your Python programs as well, but this is not the case. The Python environment that Sublime provides is for its own use, and is distinct from any version of Python you may or may not have installed on your computer.
I have a python pydev project.
Inside it I have classes.
When trying to use self. eclipse shows me the autocomplete for self and I naturally use it. Then I find that eclipse automatically adds this import line:
"from _pydevd_bundle.pydevd_cython import self"
How can I stop eclipse from importing this wrong 'self' ?
I have eclipse Version: 2019-03 (4.11.0)
Build id: 20190314-1200
and
Brainwy Software Ltda PyDev - Python Development Environment 7.2.1.201904261721 org.python.pydev.feature
interpreter is set to python 3.5
Thanks
Well, usually to write self in the editor you can type s and promptly press enter (if you have the default config PyDev would only show self as the single completion at that point... if you already have written self then you shouldn't really be asking to complete again -- i.e.: just press . or escape at that point and don't accept the completion).
Still, I agree that having that completion is a bit strange (it seems to be gotten from the cython analysis from a cython file in the PyDev debugger, which is a bit weird, so, please report this as an issue in: https://www.brainwy.com/tracker/PyDev/).
Python version: 3.4
Hi, I was running a small Python code in Pycharm, but it was terminated with the exit code 1073741819.
I've tried the same code in the Python command line and Anaconda, and both worked. Any idea why Pycharm has the problem, and how can I get it work in Pycharm? Thanks a lot.
Its too late to answer now, but maybe it helps someone else. My code also worked right with command line but not inside pycharm, it usually happens when we switch between different projects on PyCharm.
I fixed it by:
1- Restarting the Pycharm and reloading the project into it.
2- Clearing the heap memory by clicking at this in status bar:
and now it works pretty fine.
P.S: If this indicator doesnt appear then visibility of this section in the Status bar is defined by the Show memory indicator check box in the Appearance page of the Settings/Preferences dialog. It is not shown by default.
I am completely new to Python and wanted to try this code from the tutorial:
istrue = 1
if istrue:
print ("be carefull!")
The code itself should be fine, but I can not find any way to execute this code inside the editor [Komodo-Edit](http://www.activestate.com/komodo-edit)
I am used to Visual Studio and QtCreator (experienced C++/Qt developer). I would expect a menu for debugging and a command such as 'start debugging' which should open a console or use a console inside the editor. I would in any case refuse to use a dos console because then the whole idea of using an IDE would be useless.
If other Python IDEs would be more useful (on windows, no costs) I could switch to another one (except for vim/emacs).
I used to use Komodo edit, but not anymore as It's more of a text editor than an IDE. I reccomend using Ninja-IDE or Eclipse with PyDev. But if you insist on using Konodo Edit, here's an option:
Go here: Toolbox > Add > New Command...
in the top field enter the name 'Run Python file' or something else. Then go to the 'command' field and enter this:
%(python) "%F"
Optionally, you could also specify key binding for fast python executing.
I tried Komodo Edit version 9 and 10. Matthias' method work for the version 9. Version 10, I couldn't see the option to choose the Interpreter.