launching cassandra cqlsh python not found - python-2.7

I am trying to install cassandra version 2.2.0 and I found the compatible python version for it is 2.7.10 then I installed it.
when I type in terminal
python2.7 --version
Python 2.7.10
but when I launch cassandra server and want to start cassandra query language shell by typing
root#eman:/usr/local/cassandra# bin/cqlsh
bin/cqlsh: 19: bin/cqlsh: python: not found
how could I fix this issue
thanks in advance

For centos 8 and other similarly:
Install python 2.7
Then, prior to invoking cqlsh, run:
sudo alternatives --set python /usr/bin/python2

It seems that python is not installed on your machine (for whatever reason).
cqlsh shells out to python (in a rather strange way): https://github.com/spiside/cqlsh/blob/6f5b680fed2e48e37107fd1da272e351e5ac257d/cqlsh#L1-L30
Unrelated to this stackoverflow issue, I attempted to fix (and probably fixed) this in the latest version of cqlsh: https://github.com/spiside/cqlsh/commit/a880445ec9d05cfa552928d5a88d1457640456b6
If you can upgrade cqlsh it may fix this.
If you can't upgrade cqlsh any of the following things should fix this:
- If you're on an debian-like system apt-get install python-minimal -- this provides the /usr/bin/python file that seems to be missing (for whatever reason)
- If your package manager has a package which provides the /usr/bin/python symlink, install that
- Otherwise, set up a symlink that's on your path, for example ln -sf /usr/bin/python2.7 /usr/local/bin/python

Related

Python3 and aws-cli version differ

I installed aws-cli following the aws docs
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ sudo installer -pkg AWSCLIV2.pkg -target /
When I verify their existence I get different Python versions.
$ python3 --version
Python 3.9.6
$ aws --version
aws-cli/2.2.26 Python/3.8.8 Darwin/20.6.0 exe/x86_64 prompt/off
Is this expected?
yeah that's expected. The CLI doesn't use your OS'es python, one is bundled into .pkg file as well as all other dependencies. This simplifies installation, testing and development. you can mess around with your OS's python all you like without breaking the CLI.
the guts of the code for this is here:
https://github.com/aws/aws-cli/blob/v2/scripts/make-bundle
When you use sudo for installing the package you are not referring to what's specific to your user's settings, the python version is one of those settings.
Python 3.8.8 is the system installed version( System Installed
Python 3.9.6 is specific to your user's settings, you might be using pipenv or any other setting which sets the python version for you.
Hence the differences.
$›› sudo python --version
Password:
Python 2.7.16
$›› python --version
Python 2.7.16

pypy2.7.1.1 fails using pyenv

I am trying to install python version pypy2.7.1.1 using the following
pyenv install pypy2.7-7.1.1
I get the following error:
Downloading pypy2.7-v7.1.1-osx64.tar.bz2...
-> https://downloads.python.org/pypy/pypy2.7-v7.1.1-osx64.tar.bz2
Installing pypy2.7-v7.1.1-osx64...
Installing pip from https://bootstrap.pypa.io/get-pip.py...
error: failed to install pip via get-pip.py
BUILD FAILED (OS X 11.2.3 using 0000000000)
Inspect or clean up the working tree at /var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720
Results logged to /var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720.log
Last 10 log lines:
/var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720 ~
/var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720/pypy2.7-v7.1.1-osx64 /var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720 ~
ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.6. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
since pip was moved for 2.7 how do I install this now? is there a different way to install deprecated versions of python now?
I was having a similar issue on Mac OS 10.15.7 (Catalina).
This is how I was finally able to install Python 2.7 via pyenv
export GET_PIP_URL=https://bootstrap.pypa.io/pip/2.7/get-pip.py
PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl#1.0 pyenv install 2.7.5
I realize that you are trying to install pypy and not Python, but hopefully the method above helps you, or others!

Error: Problem: conflicting requests - nothing provides /usr/bin/python needed by python-chardet in CentOS 8

I am using CentOS 8 and want to download a library for Python2.
CentOS 8 has Python3 and its libraries installed by default.
I want to download python-chardet library for Python2. So I tried to install it as below -
$ sudo yum install python-chardet
I got this error -
No match for argument: python-chardet
Error: Unable to find a match: python-chardet
I searched for solution and as per this document you have to download its RPM binary and install it. https://centos.pkgs.org/7/centos-x86_64/python-chardet-2.2.1-3.el7.noarch.rpm.html
Downloading the binary file -
$ wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm
Using this rpm library I tried to install python-chardet as below -
$ sudo yum install ./python-chardet-2.2.1-3.el7.noarch.rpm
Here I got an error like this -
Error:
Problem: conflicting requests
- nothing provides /usr/bin/python needed by python-chardet-2.2.1-3.el7.noarch
Python version is
$ python -V
$ Python 2.7.16
/usr/bin/python returned this
Python 2.7.16 (default, Nov 17 2019, 00:07:27)
GCC 8.3.1 (RedHat) on linux2
Any help regarding this is much appreciated.
CentOS/RHEL 8 doesn't have any user-facing Python installed by default.
It has Python 3 installed for system apps like dnf, but to use it as a user, you need sudo dnf install python3.
Similarly, Python 2 and everything for it can be installed by using the appropriate package name suffix. To install Python 2 and the module you need:
sudo dnf install python2 python2-chardet
The recommendation/default is that the unversioned python command should not work and you should invoke the desired Python version on the shell by typing python2 instead of python.
If, for whatever reason you need unversioned python command to invoke Python 2, use the alternatives system:
sudo alternatives --set python /usr/bin/python2

Changing default Python from 2.7.10 to 3.5.2 in terminal so I can install pip

I was hoping for some help in setting up a Python development environment on a Mac.
Background: I'm running a newly upgraded macOS Sierra 10.12.1, and setting up various parts of Python development on it. This macOS version already came with Python 2.7.10 installed - and I'd prefer to leave that alone for now.
So I installed Homebrew, and then used that in turn to install the latest python3, that is, Python 3.5.2; but I guess it's not the default for Terminal yet, since when I run the python -V command, I get this in the Terminal window:
Python 2.7.10
So now I've got at least 2 version of Python on my Mac, and that's fine I guess, but the latest Python one is not the one that is the 'default'. How do I set 3.5.2 as my default rather than 2.7.10?
(Backstory for why I want to do that... pip is not installed, i.e., when I go to Terminal and type in pip, it says:
-bash: pip: command not found
When I tried to follow the installation instructions for pip, I ran into a permissions issue, which makes sense I guess, since I don't have access to the Mac's 2.7.10 Python install, nor do I really want it at this stage. So I'd like to switch Terminal to take the new Python 3.5.2 as my default one, in which case I guess I won't have pip permissions issues...)
Thanks in advance for any help folks!
The safest solution is to create a virtual environment running python 3 and use it as development environment. Check the following links:
https://docs.python.org/3/library/venv.html
http://docs.python-guide.org/en/latest/dev/virtualenvs/

Switching to Python 2.7 in Cloud9-IDE

I'm trying to change default python version to 2.7 in Cloud 9-IDE. I have managed to install correct version with command: nada-nix install python-2.7.4
It installs the version nicely, but default version stays 2.6.6.
$ python --version
Python 2.6.6
I have tried to update symbolic link to the correct version. But it says that I'm not privileged enough.
ln -nsf /usr/bin/python2.7.4 /usr/bin/python
ln: cannot remove `/usr/bin/python': Permission denied
What to do?
The Cloud9 package manager will install the python version 2.7 into ~/.nada-nix-profile/bin/python2.7. This is in your path so you can execute python2.7 from the terminal. If you want to symlink this to python just execute
$ ln -s ~/.nada-nix-profile/bin/python2.7 ~/.nada-nix-profile/bin/python
Afterwards you might have to close and reopen the terminal to activate the new version. Also the run button will then use python 2.7.