Invoking Python IDLE on Linux - linux

I am trying to set up a Python development environment. I have Python 2.7.3 running on Linux Mint 14. I downloaded IDLE and installed it. It clean installs and Python runs just fine.
So how do I invoke IDLE? There isn't any IDLE in my path: which idle returns nothing. man idle returns nothing pertaining to an editor. Nothing in /usr/lib or /usr/local/lib. Calling idle() inside the Python interpreter doesn't work. Invoking python brings up a shell, not IDLE. No menu entry for IDLE in Linux. No import library named IDLE that Python can find. Three O'Reilly books consulted and not a word about invoking IDLE in Linux. YouTube videos of Python favor Windows, not Linux. Web searches have so far been unsuccessful.

I'm not familiar with Mint myself, but since it claims to be Debian-based, try installing the idle package:
sudo apt-get install idle
That should pull in all the appropriate packages for the installed version of Python. Then you should just be able to start IDLE with:
idle
in a terminal window.

Related

"Failed to execute script pyi_rth_qt4plugins" error while running exe

I have made my application using PyQt4 and it's executable using pyinstaller. The executable runs fine on my system. My system also has PyQt5 installed.
The problem is that when I try to run the same executable on the target system(client's system), it gives me an error Failed to execute script pyi_rth_qt4plugins. The client system doesn't have Python or any version of PyQt.
I wanna know why is this happening. I'm not even able to locate where is the pyi_rth_qt4plugins located in the executable. Do I need to install Python and PyQt in my client's system as well?
As per the answer from the long thread here https://github.com/pyinstaller/pyinstaller/issues/2461
In site-packages (where PyInstaller is located) edit the following file:
PyInstaller/loader/rthooks.dat
Remove this line:
'PyQt4': ['pyi_rth_qt4plugins.py'],
This error also occurs in Python3.5 if you are using 3.5 you can downgrade to 3.4 to avoid the error
check here https://github.com/pyinstaller/pyinstaller/issues/2207
or if you don't want to downgrade python you can upgrade to PyQt5

How to use PyGObject module (gi) on Windows and PyCharm?

I have Python 3.8.1 installed and I've followed PyGObject tutorial to install the module.
I've installed MSYS2 64 bits and I certainly can import the gi module using MSYS2 terminal:
However, if I run Python from the cmd prompt or from PyCharm, it won't work:
I want to be able to run my project from PyCharm. What am I missing?
Look at the first lines that both Pythons produce. They are different.
The command-line python is a 64-bit version compiled with GCC.
The Python inside pycharm is a 32-bit version compiled with MSC.
Bottom line: Pycharm is not using the Python that you installed PyGObject in.
Edit
If you're not using the second Python instance, and nothing else on your system is using it, then it is indeed useless.
Having said that, 32-bit programs on windows have a limited adress space (2.5 GiB, IIRC). For data-science projects that might be a significant limitation these days. So I would stick to 64-bit programs these days, unless your PC has less than 4 GiB of RAM. Then it makes sense to run 32-bit software.
Another point is that I've seen reports here on Stackoverflow that Pycharm can interact negatively with Python programs that run inside it. Especially if you are running multiprocessing. So you should always test your code from a standalone Python, not from within Pycharm.

How to run GTK3 Python3 script outside of MSYS2 in Windows

How can I make my GTK3+ Python script work outside of Msys2's own Python interpreter, into my own venv (virtual environment) Python3 interpreter? I want to prepare my Python 3 script for distribution to other computers, but without Msys2.
I'm using Windows 10.
I've successfully followed the instructions on GTK's website, to download GTK3+ and the Python bindings, in Windows.
I've installed GTK3+ and the Python bindings using MSYS2. My script runs successfully within MSYS2's Python3 interpreter in C:\msys64\mingw64\bin. However, I want to run my Python script outside of MSYS2, with a separate Python 3 interpreter (venv) - not the one in MSYS2.
From my research, it seems that I need to copy the GTK3 .dll files and icons from
C:\msys64\mingw64\bin
and C:\msys64\mingw64\share
to the Python3 interpreter path that I want, with my script files in there too.
But when I attempt to run my script in the virtual environment, I get:
builtins.ImportError: cannot import name '_gi' from 'gi'
Any ideas? Thanks.
I don't know if that is possible.
But if the final intent is to distribute your app, then you should install PyInstaller inside MSYS2 and generate an executable there. Then you'll be able to distribute and execute your app on any Windows machine.
It will only be possible to run your program using the MSYS2 Python interpreter and with all of the required libraries. You can't just copy files and then run them with the Windows Python interpreter that was built using MSVC.
PyInstaller is a good solution to package an app with the interpreter and all of the libraries. The issue you mentioned about getting errors about no module named '_struct' has been fixed.

How can Python 3 be installed from command line without user input required?

I am running macOS High Sierra.
I have a .pkg installer. Using Packages I cannot add shell scripts without permission issues, so I used Automator to wrap the package and run some commands before and after installation. I want this shell script, run from Automator, to install Python 3, as it is a dependency of the application I am trying to install. The most commonly suggested option is to use Homebrew, but since this application will be installed on accounts without admin permissions, I can't do that. For reference, I don't need Python 3 installed system-wide (though that would be nice), just for it to run my application. Last thing - I tried rewriting the Python 3 code in Python 2 since that runs natively in macOS but for some reason I find "no matching distributions" when using pip to install the packages I need, all of which definitely have Python 2.7 support.
TL;DR: Is there a way to install Python 3 in such a way that it requires no user input and no admin permissions?
I was able to do a full install on raspbian.
There are ways you can do it on windows too.
This might help:
https://docs.python.org/3/using/windows.html
https://stackoverflow.com/a/46056265/10879012

How to set Python IDLE to use certain python version

I am using Windows 8.
Python version 2.7.3 have been installed on my computer together with another software.
Now I have installed python 3.3.5 and i want to use this version from now.
But everytime I run Python IDLE it runs version 2.7.3.
Even if I go to C:\Python33\Lib\idlelib\idle.pyw and run idle.pyw it runs with the 2.7.3 version.
I thought that every python version install its own IDLE so I am quiet confused here.
When I run Hello world program from the console it runs using the version 3.3.5 I have checked that.
So what I need to do is to run IDLE using 3.3.5 version
Anybody knows what to do?
Each installation of Python comes with its own respective version if IDLE. I suggest you explore your Python installation folder, and find the version of IDLE you're looking for and create a shortcut to it, or add it to your environment variable list, so you can invoke a specific version from the command line.

Resources