PyCharm doesn't list python3.6 - python

My PyCharm doesn't list the latest interpreter when choosing the location of the interpreter in the preferences.
version: PyCharm 2018.1
operating system: Linux Mint 19 Cinnamon
$ ls /usr/bin/python3*
/usr/bin/python3 /usr/bin/python3.5m /usr/bin/python3.6-config /usr/bin/python3.6-dbg-config /usr/bin/python3.6dm-config /usr/bin/python3.6m-config /usr/bin/python3-dbg /usr/bin/python3dm /usr/bin/python3m
/usr/bin/python3.5 /usr/bin/python3.6 /usr/bin/python3.6-dbg /usr/bin/python3.6dm /usr/bin/python3.6m /usr/bin/python3-config /usr/bin/python3-dbg-config /usr/bin/python3dm-config /usr/bin/python3m-config
However, in the preferences of PyCharm, python3.6 is not selectable:
When I try to select python3 from the list it still uses python3.5 even though python3 is a symbolic link to python3.6:
$ readlink -f /usr/bin/python3
/usr/bin/python3.6
In PyCharm, I still get:
>> import sys
>> print(sys.version)
3.5.2 (default, Jan 10 2018, 06:17:28)
I am configuring the [Default Settings...] and also the project settings under [Settings...]

If it is not appearing in pycharm then you can add the path. Go to Settings>Project interpreter>Virtualenv Environment>...>add. Then make sure you path to python 3.6. Also do the same thing for System interpreter. Hope that helps

Updating PyCharm might do the trick.
The Software Manager of Linux Mint currently only offers PyCharm 2018.1, but you can get a newer version by following the instruction from the official website.
Installing the latest version of PyCharm using snap might help.
$ sudo apt install snapd
$ sudo snap install pycharm-community --classic

I had the exact same issue with the Community version where I couldn't add virtual environments based on other versions of Python than 2, 3, and 3.8.
Upgrading to the Professional version magically solved the problem for me.

Related

Python Multiple version installation in Linux rocky

I am new to Python and Linux env, so a little confused.
I want to find where my Python3.9 is installed, so that I can update the PATH..
Running python --version or python3 --version give me Python 3.6.8
I want to install Python 3.9, so when I run sudo dnf install -y python39 it gives me
Package python39-3.9.12-1ep1.el8.x86_64 is already installed.
ls /usr/bin/python* doesn't show 3.9
Output of above command - /usr/bin/python /usr/bin/python3 /usr/bin/python3.6
/usr/bin/python3.6m
Also tried alternatives --config python but it shows only 3.6
-----------------------------------------------
* 1 /usr/libexec/no-python
+ 2 /usr/bin/python3
which python3.6 gives /usr/bin/python3.6
which python3.9 gives /usr/bin/which: no python3.9 in....
rpm -ql python39-3.9.12-1ep1.el8.x86_64 gives me
/etc/gdbinit.d/python39.gdb. /opt/python3.9.
/opt/python3.9/bin
I could be missing something obvious, if someone can point me in the right direction it will be awesome.
what happens when you enter the following command: python3 --version and is it any different compared to running python --version?
I am not sure what is your actual requirement is. But if you have already installed python 3.9 in your machine, then you can have this and all previous versions applied to different projects. This is selected when you create virtual environments. For example if you want to run a project that built on 3.6, then you can select python interpreter 3.6 at the time of creation.
So the virtual machine I was working was built using vagrant, it had python 3.6 in usr/bin and python 3.9 in opt/python3.9. Newbie like me who wanna understand what /opt is - https://www.baeldung.com/linux/opt-directory
To search any package used command - rpm -ql python39-3.9.12-1ep1.el8.x86_64
Once package is found add it to path as symlinking binaries can be confusing
vim ~/.bashrc
PATH=/opt/python3.9/bin

Problem in switching to python version using pyenv in windows system

I have installed pyenv in my windows system and updated it using pyenv update. When I run pyenv --version it shows 2.64.11. I installed python 3.9.9 to use in some project using command pyenv install 3.9.9. Now I open my project in visual studio code and open terminal and run the some above commands like for checking version of pyenv and pyenv versions which shows me 3.9.9 in output.Now I am in one of the directory of the D:/notification folder. Now I run pyenv local 3.9.9 and check by typing pyenv versions which shows me *3.9.9 which means 3.9.9 version is set by pyenv for this directory and for its child directories. But in meantime if I run command python --version it shows me 3.8.3 result and this is the version which I have installed from the official python.org website. I don't know why it is behaving like that. When I move to one more directory down i.e. D:/notification/notification then also the above stated problem remains as it is. Please help me in fixing this issue.

Unable to install Python 3 on OSX 10.2

I had some issues with installing Python 3 on my Mac with OSX 10.12. Now I have stuck on point when Python is installed but is not properly linked.
I installed it via homebrew by brew install python#3.9 and command python3 gives me
pavelprdel#Pavels-Mac-mini ~ % python3
Python 3.9.7 (default, Sep 3 2021, 04:31:11)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
But with command python I get
pavelprdel#Pavels-Mac-mini ~ % python
zsh: no such file or directory: /usr/local/bin/python3.9.7
pavelspurny#Pavels-Mac-mini ~ %
I have found solution via brew link --overwrite python
command but I only get this
Warning: Already linked: /opt/homebrew/Cellar/python#3.9/3.9.7
To relink, run:
brew unlink python#3.9 && brew link python#3.9
And relink doesn't work, I used which python command and it seems that it is installed in different location
python: aliased to /usr/local/bin/python3.9.7
I have also installed python from https://www.python.org/ but result is still the same.
Just link it manually:
# remove current link
unlink /usr/local/bin/python
# add new link
ln -s $(which python3) /usr/local/bin/python
Also check $PATH variable:
echo ${PATH}
...:/usr/local/bin:/usr/bin:/bin:/usr/sbin:...
/usr/local/bin must prepend /usr/bin because here is default python 2.x interpreter /usr/bin/python and /usr/local/bin/python must be called first
Also I don't recommend to override system's /usr/bin/python with python3, it should be reverted if already overridden
Check for upvoted 41 times warning (However that is not a so big problem for mac OS in compare to Linux OS):
Just a warning: Do not attempt to change the /usr/bin/python symlink to point to python3 instead of 2.7. Many programs available in the Ubuntu repos require /usr/bin/python to be compatible to python 2.x.
Anyway usually the python is used to run python 2.x and the python3 to run python 3.x. I recommend to use pyenv (for shell session scope) or virtualenv (for project scope) to be able override python with python3 only where it needed.
In other cases execute python 3 via python3 command is a normal practice
A better way to install python is by downloading it from the following link:
https://www.python.org/. Then, click on the download tab and select the newest version.
This should fix your problem. Installing via brew might be outdated and does not always work on OSX.

Different python versions both os and pycharm

I am running on Ubuntu 18.04 and using Pycharm 2020.1. My system using Python version 3.7.6 and Pycharm using 3.6. And this makes conflicts.
$ python --version
Python 3.7.6
$ ls /usr/bin/python*
/usr/bin/python /usr/bin/python2.7 /usr/bin/python3.6 /usr/bin/python3m
/usr/bin/python2 /usr/bin/python3 /usr/bin/python3.6m
I tried to change python interpreter but not showing in the list. What can I do for using same version both os and pycharm?
You need to choose System Interpreter option not Virtual Environment.
However, is highly not recommended.

How to check all versions of python installed on osx and centos

I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.
The more easy way its by executing the next command:
ls -ls /usr/bin/python*
Output look like this:
/usr/bin/python /usr/bin/python2.7 /usr/bin/pythonw
/usr/bin/python-config /usr/bin/python2.7-config /usr/bin/pythonw2.7
we can directly use this to see all the pythons installed both by current user and the root by the following:
whereis python
Find out which version of Python is installed by issuing the command
python --version:
$ python --version
Python 2.7.10
If you see something like this, Python 2.7 is your default version. You can also see if you have Python 3 installed:
$ python3 --version
Python 3.7.2
If you also want to know the path where it is installed, you can issue the command "which" with python and python3:
$ which python
/usr/bin/python
$ which python3
/usr/local/bin/python3
Here is a cleaner way to show them (technically without symbolic links). This includes python2 and python3 installs:
ls -1 /usr/bin/python* | grep '.*[2-3]\(.[0-9]\+\)\?$'
Where grep filters the output of ls that that has that numeric pattern at the end ($).
Or using find:
find /usr/bin/python* ! -type l
Which shows all the different (!) of symbolic link type (-type l).
Use, yum list installed command to find the packages you installed.
COMMAND: python --version && python3 --version
OUTPUT:
Python 2.7.10
Python 3.7.1
ALIAS COMMAND: pyver
OUTPUT:
Python 2.7.10
Python 3.7.1
You can make an alias like "pyver" in your .bashrc file or else using a text accelerator like AText maybe.
As someone mentioned in a comment, you can use which python if it is supported by CentOS. Another command that could work is whereis python. In the event neither of these work, you can start the Python interpreter, and it will show you the version, or you could look in /usr/bin for the Python files (python, python3 etc).
It depends on your default version of python setup. You can query by Python Version:
python3 --version //to check which version of python3 is installed on your computer
python2 --version // to check which version of python2 is installed on your computer
python --version // it shows your default Python installed version.
compgen -c python | grep -P '^python\d'
This lists some other python things too, But hey, You can identify all python versions among them.
Sift through the output of this script.
sudo find / -name 'python*' -type f -exec du -h {} + | sort -r -h ~/Documents/python_locations.txt
ls -l /usr/bin/python* & ls -l /usr/local/bin/python*
I would add to #nurealam siddiq answer,
python --version // it shows your default Python installed version.
python2 --version // to check which version of python2 is installed
python3 --version //to check which version of python3 is installed
python3.X --version // to further check which python3.X is installed
To check python versions installed in your OS you can run the below commands:-
python2 -version
python3 -version

Categories