I had two versions of python installed (python - 2.7.12 and python3 - 3.5.2). After installing python 3.7.7, I wanted to make it the default of the python3 command by making a few commands. But unfortunately, the python3 command no longer works!
fogang#FF:~$ python
Python 2.7.12 (default, Oct 8 2019, 14:14:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
fogang#FF:~$ python3.7
Python 3.7.7 (default, Mar 10 2020, 17:25:08)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
fogang#FF:~$ python3
bash: /usr/lib/command-not-found : /usr/bin/python3 : mauvais interpréteur: Aucun fichier ou dossier de ce type
fogang#FF:~$
Translated: "/usr/bin/python3: bad interpreter: No file or folder of this type"
There is my /usr/bin
fogang#FF:/usr/bin$ ls python*
python python2.7-config python3.5-config python3.7 python3.7m-config python3m-config pythontex3
python2 python2-config python3.5m python3.7-config python3-config python-config
python2.7 python3.5 python3.5m-config python3.7m python3m pythontex
/usr/bin/python3 is missing. Based on the comments, you're using Ubuntu, so the solution is to simply reinstate it:
sudo ln -s python3.5 /usr/bin/python3
Note that changing the system python3 version on Ubuntu will break things, so the better solution is to use an alias, e.g. put alias python3="python3.7" in your bashrc.
Related
I have pyenv installed and everything works pretty well except for one aspect: when I run the command python3.9, my system still points to my system's version of python (3.9.13). However, I would like to make it point to my pyenv installed version when running python3.9:
❯ pyenv versions
system
3.7.10
3.8.10
* 3.9.5 (set by /Users/username/.python-version)
❯ python3
Python 3.9.5 (default, Jul 7 2022, 20:35:58)
[Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
❯ python3.9
Python 3.9.13 (main, May 24 2022, 21:13:51)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
❯ python3.9 --version
Python 3.9.13
❯ python3 --version
Python 3.9.5
Note that the issue occurs just when running python3.9, not python3.
What's wrong in my configuration?
My mac came with Python2 by default. I installed Python3 using Homebrew (brew install python3) and did something to get python to point to python3 in Terminal. Unfortunately I can't remember what I did (I must have casually copied and pasted a couple lines of commands to get python set to python3). Now that I want to find out what I did that was forgotten, I looked everywhere in my $PATHS, my .bash_profile, .zhrc etc but I found nothing set for python or python3 - no PATHs written, no aliasing either.
How is that possible and what else could I have done?
My Python versions:
my-mac:~ myname$ python2
Python 2.7.16 (default, Feb 28 2021, 12:34:25)
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
my-mac:~ myname$ python
Python 3.9.6 (default, Jun 29 2021, 05:25:02)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Here are all my PATHs:
my-mac:~ myname$ echo "${PATH//:/$'\n'}"
/Users/myname/.rvm/gems/ruby-1.9.3-p327/bin
/Users/myname/.rvm/gems/ruby-1.9.3-p327#global/bin
/Users/myname/.rvm/rubies/ruby-1.9.3-p327/bin
/Users/myname/.rvm/bin
/usr/local/mysql/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Library/TeX/texbin
/Users/myname/Qt/5.5/clang_64/bin/
Checking Python and Python3 paths:
my-mac:~ myname$ type python
python is hashed (/usr/local/bin/python)
my-mac:~ myname$ type python3
python3 is /usr/local/bin/python3
My .bash_profile and .zshrc content:
my-mac:~ myname$ nano .bash_profile
export PATH="/usr/local/mysql/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
my-mac:~ myname$ nano .zshrc
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
brew install the binaries at /usr/local/bin which is before /usr/bin in your PATH. (brew updates the PATH to include it prior to the systems /usr/bin). You don't need to do anything to put brew installed apps in your PATH, it's already there.
Try which python and see where it points. Here's an example of MacOS default interpreter.
➜ which python
/usr/bin/python
➜ python
Python 2.7.16 (default, Jun 18 2021, 03:23:53)
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
If you want python to point to the system's Python 2.x, you can delete /usr/local/bin/python. Then to use Python3, you'll need to specify python3. (which is located at /usr/local/bin/)
You can list /usr/local/bin which contains symlinks to the actual binaries.
➜ ll /usr/local/bin | grep python
lrwxr-xr-x 1 usr admin 38B Sep 5 12:27 python3 -> ../Cellar/python#3.9/3.9.6/bin/python3
lrwxr-xr-x 1 usr admin 45B Sep 5 12:27 python3-config -> ../Cellar/python#3.9/3.9.6/bin/python3-config
lrwxr-xr-x 1 usr admin 40B Sep 5 12:27 python3.9 -> ../Cellar/python#3.9/3.9.6/bin/python3.9
I have installed cassandra 3.0.0 and trying to connect to connect cqlsh. when i try to hit ./bin/cqlsh from the dir of installed cassandra I am getting
python not found. I am using ubunut14.04LTS
when i type python2 in my terminal it says
python2
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
when i type python3 in my terminal it says
python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
so this mean it is already installed . But yes when i type
python in terminal it says
python
The program 'python' is currently not installed. You can install it by typing:
apt-get install python-minimal
even when i install python-minimal it doesn work.
please suggest..
Create a symbolic link /usr/bin/python pointing to either /usr/bin/python2 or /usr/bin/python3
~$ python
bash: python: command not found
while running python2 and python 3 its showing different versions.
~$ python2
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
~$ python3
Python 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
i think somehow default python link is broken. i can't seem to access ubuntu software center also.
Please suggest a way to fix this.
Rather than re-creating the simlink as suggested, I would start working with virtualenv. You can create virtual environment pointing at different python versions by doing:
virtualenv -p /usr/bin/python2 venv_name (for Python 2.7)
virtualenv -p /usr/bin/python3 venv_name (for Python 3)
Once you go into the venv and do the source venv_name/bin/activate, your python symbolic link will be pointed at the version you've chosen when creating it.
Also, you might find a pyvenv link which will be associated to Python 3 as this version of Python comes with virtualenv (and pip) out of the box. You might need to install virtualenv with pip (or easy install), and to figure it out which Pythonversion is your pip associated to, you can do pip --version
i update python from 2.7.3 to 2.7.9 in raspberry ..
first i download source from python.org and configure & make & make install
no when i command python in terminal python 2.7.9 executed ...
Python 2.7.9 (default, Jan 27 2015, 21:20:44)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
but all module that i installed from apt-get install is now unknown ...
like sudo apt-get install python-bluez
how can i fix it ?