Python Interpreter not showing anything in PyCharm - python

Issue
So, I've used PyCharm for quite a while and I know how to set environments, etc. For some reason, I can't seem to access the Python interpreters that I've got (see image).
When I open the same project in Clion I am able to run the files and I can see the interpreters.
Attempted solutions
Run in Clion to see if the interpreter "sticks".
Removed the .idea file.
Reinstalled PyCharm.

Usually Python Interpreter is a sub-item of Build, Execution, Deployment in the Settings. (In PyCharm 2021, the layout in PyCharm 2019 was slightly different).
The fact the item appears separately is a strong hint that you either installed a plugin or for some reason the IDE was opened in LigthEdit mode (this can easily happen if you launch the IDE using the command-line). This can also happen if you don't have an open project (having files open is not the same as opening a project, as such, with an .idea folder - the IDE configuration files will be different.)
Having the IDE in LightEdit mode provides only a limited set of functionalities, so the IDE doesn't allow you to configure an Interpreter in the usual way (other setting dialogues will also behave different from usual).
The solution is to Exit the LightEdit mode, opening your previous project or a new one by going to File > Open or File > New Project.

Related

Cannot open idle on Mac

I have python3.7.2 and idle installed on my mac, both of them came from the official installation package, run without problem for months, until recently I changed my terminal shell to zsh and also installed another version of python when homebrew is trying to have it as a dependency.
Then today any .py file cannot be opened by the idle app, I uninstalled the homebrew version of python, removed the frameworks and the links in /usr/local/bin, but the idle app still cannot be opened. Although the app version cannot be opened, it can be opened by "idle3" in my command line. What's more the python launcher works just fine.
Then I removed all the versions of python3 installed, used app cleaner to clean the saved state stuff and cleaned all the links used by python3 in /usr/local/bin. Later I installed the python3.7.7 and idle using official .pkg installer. Still idle cannot be opened by double clicking on it. But this time things get even worse, the idle can be opened indirectly sometimes at a nearly random probability if I try to double click on .py files. And even python launcher cannot open .py files in terminal. Now I have no idea how things are going. Can anyone help to analyze how this kind of weird problem occurred?
Here is the diagnosis and solution, by Ned Deily on the Python tracker, that worked for Steve.
It appears that if the Files & Folder security setting is set to disallow access to your Documents Folder, IDLE.app will fail on startup but it will launch from the command line. Check the following in System Preferences.
Apple Menu (upper left corner) -> System Preferences -> Security & Privacy.
Then click on the Privacy tab, scroll to and click on Files and Folders, then look for a Python.app (not IDLE.app) entry. It should have a Documents Folder entry underneath it and it should be checked (enabled). If not, click it (you might need to click on the lock in the lower left corner to enable changes).
Control-Click on the Python file and open with a different version of Idle via "Open With".

VSCode Python package inspection failure

This's probably quite off-topic but maybe someone else share my experience... when I started coding KiCAD plugins and learning Python I decided to use VSCode (with Microsoft Python extension) because I already use it for a number of other things and works great.
I have two main issues mostly bound to Python extension itself other than VSCode:
VSCode try to use python 3.7 binary (I installed it on my
machine and I need it) instead kicad/python 2 (it's installed on a different location);
even if I setup VSCode to look for additional packages with a specific configuration file (settings.json):
"python.autoComplete.extraPaths": ["C:/Program Files/KiCad/lib/python2.7/site-packages"]
VSCode refuse to investigate pcbnew.py (located in that folder) and thus every Intellisense like function (inspection etc) doesn't work.
How can I fix that? ... I'm more interested in fixing the second issue other than the first.
To correctly enable per project configuration of VSCode / Python open folder and create a workspace configuration for the project itself (i.e. create a .vscode folder inside project folder and store a settings.json file inside it with you custom configuration). In my specific case I needed to specifiy a custom location for an older Python binary trough python.pythonPath directive.

PyCharm crashes when I start typing

I am using PyCharm Community Edition and tried versions 2019.1.3 and 2019.1.2. I can create a new project and files to that project but as soon as I write anything (e.g: in a .py file, in a .html file or even entering the script path when adding a configuration) it crashes (also crashes when trying to edit an already existing project). Any suggestions what I can do to fix that?
Go to Preferences/Appearance and select a different font, I used "Monospace" and things seem to work again.
On my system, PyCharm was crashing when it called into CoreText rendering. Reinstalling and trashing preferences otherwise didn't work.

PyDev Debugging

My interpreter is the python 2.6 interpreter that comes with cygwin.
I have a pydev project that contains a linked folder.
In the folder, due to outside constraints, I have two sub-folders, one with a bunch of scripts I develop, and one which serves as the run directory for all my run configurations.
When I run the project (not debug) everything works fine.
However, when I choose to debug the project, my custom modules aren't found, and the import fails.
I tried adding my scripts folder to PYTHONPATH, but that didn't help, and when I printed sys.path It contained weird stuff, all of the form:
<path to run directory>/<path to entry in PYTHONPATH>
I can't make heads or tails out of it.
I'll appreciate any help.
Unfortunately, that's a known issue. PyDev does not support Cygwin for debugging. The primary reason is that the paths that Python reports don't match the paths you configure in windows, so, a translation step would be needed for each path (even some other areas such as code-completion or code-analysis could have problems).
You can probably do this translation yourself at eclipse/plugins/org.python.pydev_x.x.x/pysrc/pydevd_file_utils.py (instructions on the file), but note that this may be more work than it's worth (the recommended approach is using a native Python install on Windows instead of through cygwin) -- or if you need an interpreter on Linux, develop on Linux :)
Thanks, you made my day, its actually very easy,
you have to change the PATHS_FROM_ECLIPSE_TO_PYTHON variable inside pydevd_file_utils.py as,
PATHS_FROM_ECLIPSE_TO_PYTHON = [
(r'C:\Users\usernam\workspace-cpp\python-proj\src',
r'/cygdrive/c/Users/usernam/workspace-cpp/python-proj/src')
]
But this needs to be changed for all your own python source files you desire to debug
I am happy to announce a new release of ePyUnit, which solves the load-path issue of 'pydevd.py'. This works from within Eclipse/PyDev as well as from an arbitrary process started from the command line.
ePyUnit now includes the automation of remote debugging with PyDev and Eclipse by 'pydevd.py'. This works seamlessly for the 'subprocess' call as well as independently started command line processes.
See:
https://pypi.python.org/pypi/epyunit
https://pythonhosted.org/epyunit/
For basics of remote debugging:
http://www.pydev.org/manual_adv_remote_debugger.html
Also enhanced unittest integration into PyUnit.
Comments and fixes are welcome.
Have fun...

Force eclipse to reload Python modules

I have started a Eclipse PyDev project, and found out that BeautifulSoup was missing.
I installed it using easy_install, and now the scripts runs fine from the command line. Eclipse, however, still thinks that BeautifulSoup isn't installed, displaying an annoying error message and not supplying any introspection or auto complete.
How can I force Eclipse to reload the system's python package list?
You have to reconfigure the python interpreters. Normally the automatic configuration utility should discover everything by itself, but otherwise you can manually add/remove packages. Here's a screenshot of where the settings are located:
In the only occasion in which I can recall I needed to do that, all I did was to remove the python interpreter from the list and running the Auto Config procedure again, but it should also be possible to simply add a library (bottom half of the screenshot).
HTH!

Categories

Resources