cassandra 2.2 CQl Shell supports python 2.7 - cassandra-2.0

Error I am get when trying to start cql Shell
>cqlsh
CQL Shell supports only Python 2.7
>
I have installed python2.7 but it is still giving the same error.
do i have to set path some were?
i have installed Cassandra 2.2 from datastax suing this command
sudo yum install dsc22

Depending on your distribution and its version you cannot change the default python version of the system without breaking the system. If you have Python 2.7 installed then its interpreter is probably on your path as python2.7.
Try running python2.7 --version. If that gives you an output like Python 2.7.x you are good. Just edit the cqlsh script and replace python with python2.7 at the beginning of the only code line in the file.

You should use python 2.7 but be aware of https://issues.apache.org/jira/browse/CASSANDRA-11850

Not enough rep to post as a comment. If you encounter same problem as #andrewdeal and you installed Python 2.7 side-by-side (a must on CentOS 6 which requires Python 2.6), you need site-packages in your Python 2.7 install.
As root:
rm /usr/local/lib/python2.7/site-packages/README
rmdir /usr/local/lib/python2.7/site-packages
ln -s /usr/lib/python2.7/site-packages/ /usr/local/lib/python2.7
You can now run cqlsh

I tried doing that change from python to python2.7 and then got:
Traceback (most recent call last):
File "/usr/bin/cqlsh.py", line 152, in <module>
from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling
ImportError: No module named cqlshlib

Related

google drive api and pip problems with pycharm and anaconda on macos [duplicate]

I'm trying to use pip to install a package. I try to run pip install from the Python shell, but I get a SyntaxError. Why do I get this error? How do I use pip to install the package?
>>> pip install selenium
^
SyntaxError: invalid syntax
pip is run from the command line, not the Python interpreter. It is a program that installs modules, so you can use them from Python. Once you have installed the module, then you can open the Python shell and do import selenium.
The Python shell is not a command line, it is an interactive interpreter. You type Python code into it, not commands.
Use the command line, not the Python shell (DOS, PowerShell in Windows).
C:\Program Files\Python2.7\Scripts> pip install XYZ
If you installed Python into your PATH using the latest installers, you don't need to be in that folder to run pip
Terminal in Mac or Linux
$ pip install XYZ
As #sinoroc suggested correct way of installing a package via pip is using separate process since pip may cause closing a thread or may require a restart of interpreter to load new installed package so this is the right way of using the API: subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'SomeProject']) but since Python allows to access internal API and you know what you're using the API for you may want to use internal API anyway eg. if you're building own GUI package manager with alternative resourcess like https://www.lfd.uci.edu/~gohlke/pythonlibs/
Following soulution is OUT OF DATE, instead of downvoting suggest updates. see https://github.com/pypa/pip/issues/7498 for reference.
UPDATE: Since pip version 10.x there is no more get_installed_distributions() or main method under import pip instead use import pip._internal as pip.
UPDATE ca. v.18 get_installed_distributions() has been removed. Instead you may use generator freeze like this:
from pip._internal.operations.freeze import freeze
print([package for package in freeze()])
# eg output ['pip==19.0.3']
If you want to use pip inside the Python interpreter, try this:
import pip
package_names=['selenium', 'requests'] #packages to install
pip.main(['install'] + package_names + ['--upgrade'])
# --upgrade to install or update existing packages
If you need to update every installed package, use following:
import pip
for i in pip.get_installed_distributions():
pip.main(['install', i.key, '--upgrade'])
If you want to stop installing other packages if any installation fails, use it in one single pip.main([]) call:
import pip
package_names = [i.key for i in pip.get_installed_distributions()]
pip.main(['install'] + package_names + ['--upgrade'])
Note: When you install from list in file with -r / --requirement parameter you do NOT need open() function.
pip.main(['install', '-r', 'filename'])
Warning: Some parameters as simple --help may cause python interpreter to stop.
Curiosity: By using pip.exe you actually use python interpreter and pip module anyway. If you unpack pip.exe or pip3.exe regardless it's python 2.x or 3.x, inside is the SAME single file __main__.py:
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
To run pip in Python 3.x, just follow the instructions on Python's page: Installing Python Modules.
python -m pip install SomePackage
Note that this is run from the command line and not the python shell (the reason for syntax error in the original question).
I installed python and when I run pip command it used to throw me an error like shown in pic below.
Make Sure pip path is added in environmental variables. For me, the python and pip installation path is::
Python: C:\Users\fhhz\AppData\Local\Programs\Python\Python38\
pip: C:\Users\fhhz\AppData\Local\Programs\Python\Python38\Scripts
Both these paths were added to path in environmental variables.
Now Open a new cmd window and type pip, you should be seeing a screen as below.
Now type pip install <<package-name>>. Here I'm installing package spyder so my command line statement will be as pip install spyder and here goes my running screen..
and I hope we are done with this!!
you need to type it in cmd not in the IDLE. becuse IDLE is not an command prompt if you want to install something from IDLE type this
>>>from pip.__main__ import _main as main
>>>main(#args splitted by space in list example:['install', 'requests'])
this is calling pip like pip <commands> in terminal. The commands will be seperated by spaces that you are doing there to.
If you are doing it from command line,
try -
python -m pip install selenium
or (for Python3 and above)
python3 -m pip install selenium

Does python 3.8.2 have ensurepip? Do I need to install ensurepip to use it?

I'm using python 3.8.2 on ubuntu on windows 10. I'm reading an OOP pdf and I'm at the third-party libraries section. It says that pip doesn't come with python, but python 3.4 contains a useful tool called ensurepip, which will install it: python -m ensurepip.
But when I press enter, it says no module named ensurepip
/usr/bin/python3: No module named ensurepip
So I thought that I already have pip so I tried to install pygame with pip but it says there's no module named pip. What am I doing wrong?
Thanks.
The module ensurepip is part of Python's standard library. It should be there. You say you're on Windows, but then you show /usr/bin/python3 in your question, which is obviously not a Windows path (rather Linux).
My assumption is that you might be using WSL (or WSL2), which is actually Linux running on Windows (without going into details). By default WSL runs a Ubuntu distribution. This distribution (and other Debian-related distributions) typically breaks up Python and its standard library in multiple pieces.
So you might need to install an additional system package, I believe it could be the python3-venv system package that contains the Python ensurepip module in your case:
sudo apt-get install python3-venv

How can i download paho and pip on my Windows 10

I am currently programming in IronPython 2.7 and would like to integrate Paho.
Since I became IronPython 2.7, I have to download Python 2 and not Python 3.
when I get the command
pip install paho-mqtt
heard in my Windows 10 terminal
what error message appears:
DEPRECATION: Python 2.7 reached the end of its life on January 1, 2020. Please update your Python as Python 2.7 is no longer maintained. pip 21.0 will end support for Python 2.7 in January 2021. Further information on Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2- support
Requirement already fulfilled: paho-mqtt in c: \ python27 \ lib \ site-packages (1.5.0)
has an idea what I have to do?
Python you are using must be below the minimum supported version of for Python 2, and that's why you get the error.
Paho-MQTT does not work with Python versions below 2.7.9, according to their
documentation.
Try this:
Delete your current Python.
Install the newest python from their website, install it on PATH.
Verify that your installation was successful with cmd -> python (should show your version, i.e Python 3.8.3)
Install your package with cmd -> pip install paho-mqtt

Version of Python when running Ansible commands

I am using OSX.10.12.6.
I installed ansible via pip3 (in order to use it with Python3 considering Python2 is already installed on my machine by default) and downloaded the ec2.py external inventory script from Ansible github
But when running ansible commands, I get the error:
[WARNING]: * Failed to parse
~/ec2.py with script plugin: Inventory script
~/ec2.py) had an execution error: Traceback (most recent call last): File
"~/ec2.py", line 130, in <module> import boto ImportError: No module named boto
It seems to be because ansible is using Python2 instead of Python3 (I checked, I cannot import boto or ansible from Python2 but I can from Python3). Also I can run successfully the following python3 ec2.py
What is surprising is that if I run ansible --version, I get the following:
ansible 2.8.3
config file = ~/ansible.cfg
configured module search path = ['/Users/XXXX/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.5 (default, Mar 30 2018, 06:42:10) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
Is there anything I can do to "force" ansible to use Python3 instead of Python2?
PS: Note that I can get through the initial error by pip install boto on Python2, but others error pop up and would rather use Python3
FreeBSD Quarterly (Stable) Ports Branch released today 2019Q3 has Ansible 2.7.10. HEAD upgraded to Ansible 2.8.3 last Sunday! The conclusion is, FreeBSD decided not to put 2.8.3 into the STABLE branch. Probably one of the reasons is the new feature in Ansible 2.8 Python interpreter discovery. See Using FLAVORS. Hence either you downgrade to Ansible 2.7, or you proceed with fixing the HEAD (in MacOS).
It might be worth to try and set ansible_python_interpreter to Python 2.7.
(Some might argue it's rather a comment. I started there, but it's too long.)

tensorflow installation issues:ImportError: No module named tensorflow

environments: Ubuntu 14.04(64bit) Python2.7.11
Firstly, I installed tensorflow in the way of Virtualenz installation.
$ sudo apt-get install python-pip python-dev python-virtualenv
$ virtualenv --system-site-packages ~/tensorflow
$ source ~/tensorflow/bin/activate
$export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp27-none-linux_x86_64.whl
$ pip install --upgrade $TF_BINARY_URL
and then, I test my installation and some issue appear. I know I didn't install tensorflow successfully.
import tensorflow
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named tensorflow
import tensorflow as tf
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named tensorflow
I don't know how to solve the problem. Please help me, it cost me one day. I tried to uninstall tensorflow and then I installed in the way of pip installation. But I get the same error.
The protocbuf is 3.1.0.
Are you running python in the same virtual environment you installed tensorflow in?
To access your tensorflow installation, you have to first "activate" the virtualenv in any new terminals, as follows:
source ~/tensorflow/bin/activate
python
import tensorflow as tf
If you run the above in a new terminal, does it solve your problem?
When you did
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp27-none-linux_x86_64.whl
this step you are specifying that you are going to use Nvidia card.
To run tensorflow with GPU(Nvidia graphics card) you need to satisfy all Nvidia requirements
Nvidia requires some special privileges to its CUDA cores
You also need to check for Cuda pathnames to the LD_LIBRARY_PATH environment variable, check in Nvidia Documentation.Also, you need to install an profiling support, this can be done by libcupti-dev library, which is the NVIDIA CUDA Profile Tools Interface. This library provides advanced profiling support. To install this library, issue the following command:
sudo apt-get install libcupti-dev
But if you want to run tensorflow in CPU mode only, do not specify $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp27-none-linux_x86_64.whl.With this you are overriding TF_BINARY_URL variable to use Nvidia CUDA core
So, to use CPU from all your steps remove $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp27-none-linux_x86_64.whl and include only $export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl and reinstall
I hope this should clear the problem
In case, your prerequisite python packages are not installed properly,
check several things.
$ source $HOME/tensorflow/bin/activate
$ which python
$ which pip
please check these binaries are in the path $HOME/tensorflow/bin/activate. If so, try
$ pip install -I --upgrade $TF_BINARY_URL
where -I option forces to install packages.
INSTALLATION OF TENSORFLOW ON UBUNTU 18.04
download anaconda python package
install it via shell using bash
$bash anaconda*.sh
editing the .bashrc script //location home
$sudo apt-get install python3-pip
$sudo apt-get update
$cd
$nano .bashrc
nano is the text editor
insert the given line at the end of the file
export PATH=-/anaconda3/bin:$PATH
create a virtual environment
using conda
$conda create -n myenv python=3.5
//SPECIFY THE VERSION REQUIRED DO NOT USE 3.7 AS THERE IS A COMPATIBLITY ISSUE WITH TENSORFLOW 10
$source activate myenv
$pip install -U tensorflow
$python
>>import tensorflow as tf
>> //get this prompt without an error it means the installation is successful
>>exit()
source deactivate
fully tested if an issue arises do let me know
whenever you install python packages i would suggest to do it in a virtual environment

Resources