Start IDLE with python 3 on Linux (python 2.7 installed alongside) - python

I initially had Python 2.7, which often comes bundled with the OS (currently using Linux Mint 12). I wanted to try Python 3, so I installed it alongside Python 2. All is fine there, and I can run both versions in the terminal by calling either python or python3.
However, there doesn’t seem to be any way to start IDLE with Python 3. Is there some flag that I can pass to IDLE when I start it so that I can pick which version of Python I would like it to run?
E.g. (these don't work),
idle3 or idle --shell=python3 or something like that. I read about pointing to a different executable in this question about IDLE for Python 3 (on Vista). However, I can't seem to do the analogous thing on Linux.

Just type sudo apt-get install idle3 in your terminal and IDLE for your version of Python 3 previously installed will be installed.
Then both are compatible. You run the 2.7 IDLE from your terminal by just typing idle. And you run the IDLE 3 version by just typing idle3 in the terminal. That worked for me.

You'd have to install the appropriate package - Python 2.x and 3.x aren't compatible with each other.
You can find the link here.

I had to install python3-tools to get idle3 (using Fedora 18).

I installed IDLE using the following command:
sudo yum install python-tools.x86_64
And I can run both commands, and it gives me a Python 2 or Python 3 shell, respectively:
idle
idle3

Christy said:
"I had to install python3-tools to get idle3 (using Fedora 18)."
sudo yum install python3-tools
This also works on Fedora 19.

In the case of Python 2, you can install it by running this command:
sudo apt-get install idle
And in the case of Python 3 you can install it by running this command:
sudo apt-get install idle3
This works fine for me.

Related

3rd party libraries of Python cant be used on MSYS2 terminal, how to use them in MSYS2 terminal?

OS: windows 10
I install python3.9, pip install many 3rd party packages and use them well on both Pycharm and CMD terminal;
Later, I install MSYS2 and then I tpye 'python' on the terminal of MSYS2 and get into python terminal; it seems well until now. When I import sth, getting the warning "No module named 'xxx'" which can be imported well on Pycharm or CMD terminal.
so I guess the path of 3rd party packages not be included for MSYS2, how to resovle it?
Here is the standard way to use Python 3 and pip in MSYS2:
Select the "MSYS2 MinGW 64-bit" shortcut or run mingw64.exe to start a MinGW 64-bit shell. (32-bit should work too.)
Run pacman -S $MINGW_PACKAGE_PREFIX-{python3,python3-pip} to install both Python 3 and pip.
Run pip install PKGNAME to install a package you need.
Run python path/to/script.py to run your script.
I tested these instructions just now. I was able to run pip install pyserial and then I was able to run a script that started with import serial.

Python version mismatch during building a code

I am trying to compile a code that works with Python 3.6. On my computer (Ubuntu 20.04), Python 2.7 and 3.8 comes pre-installed. Therefore, I manually installed python 3.6 using apt-get (I am not using any third party software e.g. Anaconda). I've also installed the development branch of 3.6 (something like libpython-dev).
However, when the code compiles, it needs to install certain packages (mpi4py, h5py etc) which should correspond/build with Python 3.6. However, the process detects Python version as 3.8. I have done the following in order to force the system to use 3.6 version:
In my bashrc file, I have created an alias for python (and python3) as python3.6
alias python='python3.6'
alias python3='python3.6'
The output of 'sudo update-alternatives --config python' is:
The output of commands python --version, python -V is Python 3.6.13. Therefore, I do not understand as to how to make the code works with 3.6. Please help!
You can install these packages using :
python3 -m pip install mpi4py(package_name) or
python3.6 -m pip install package_name

Linux Terminal ./code.py operates using Python 2.7.13 while the IDLE uses Python 3.5.3

Using a Debian-based Linux distro (Kali) for Python programming (note that I am very new to Linux, had it for less than 2 months). Installed Python and GitKraken the usual way with apt-get install.
Started happily coding using the 3.5.3 IDLE, but when I tried to use pip commands to install modules (all of this as root user), I found it was installing to /usr/local/lib/python2.7/dist-packages rather than the Python 3.5.3 location (/usr/local/lib/python3.5/dist-packages).
When I used pip install module, it installed all modules to the 2.7 location. Because the Terminal used 2.7 by default (for whatever reason), using ./code.py always ran code using Python 2.7, but I wrote the code for Python 3.5 (not the version the modules were installed for).
I saw some other answers on this website for similar problems, where you have to install new modules and change the PYTHONPATH variable and assign aliases, but it messed more stuff up. Now echo $PYTHONPATH returns nothing, and pip still installs to the Python 2.7 location.
I used apt-get to install python-pip3 and I use the pip3 command to install modules, but whenever I use ./code.py (my main method to run code), it still uses Python 2.7. How can I change this?
Edit the shebang at the first line of code.py to point to your Python 3.5 binary, e.g.:
#!/usr/bin/env python3
Or if it's not linked as python3 figure out were your Python 3.5 binary is and use that.

How can I install python-gasp on Ubuntu 16.04?

I use a Ubuntu 16.04 system, and I want to install the gasp for python.
I was told that the following commands can help me to install the python-gasp:
$ sudo apt-get install python-gasp
I tried the commands, but it seems not to work, because when I run
from gasp import
it returned as
"No module named gasp".
Then I use $ whereis python-gasp to check the location of the python-gasp I installed, and it returned as /usr/share/python-gasp
I don't know what happened.
How can I use gasp successfully?
python-gasp is module for Python 2. I don't see python3-gasp for Python 3 (Linux Mint 17 based on Ubuntu 14.04) but maybe you have on Ubuntu 16.
Ubuntu 16 as default use Python 3. Maybe you will have to install Python 2 to use gasp.
Or maybe you already have installed. Try python2 or which python2 to find path.

How to properly install python3 on Centos 7

I'm running Centos7 and it comes with Python2. I installed python3, however when I install modules with pip, python3 doesn't use them. I can run python3 by typing python3 at the CLI
python (2.x) is located in /usr/bin/python
python3 is located in /usr/local/bin/python3
I tried creating a link to python3 in /usr/bin/ as "python", but as expected, it didnt resolve anything. I renamed the current python to python2.bak It actually broke some command line functionality (tab to complete). I had to undo those changes to resolve.
Suggestions welcome. Thanks.
The IUS project has ready to go RPM packages of python34u-pip, python35u-pip, and python36u-pip. These will give you corresponding pip3.4, pip3.5, and pip3.6 commands. As expected, the packages installed by those will be available to the corresponding python3.4, python3.5, and python3.6 interpreters.
Do you have pip for python3, too? Try pip3 rather than pip. I assume your regular pip is just installing the modules for Python 2.x.

Categories

Resources