Apache Cassandra, cqlsh command, issue on windows 10 and python - python

On my computer, I run 3 versions of python, py2.7, py3.8 and py3.9, so I changed the .exe name to python27, python38 and python39. Now I can uninstall py3.8 but I not py39 because I need it to work in another project. So, the different versions of python seem to work correctly as evident here.
All different python versions seems to run correctly and also cassandra -f command outputs (nodetool status get ok).
But now, when I use cqlsh command I get following error
can't detect python version
However, I tried to use the command python27 cqlsh, it runs successfully but I got another error here that I have no idea on how to fix.
I hope someone can help me and i apologise for my english, if i made mistakes.

I have this problem, too. My solution is to carry out the order "python2 -m cqlsh". You need change "python2" to your python2’s name.

Related

Why is my $PATH (seemingly) not working when trying to use Python in my terminal?

I know there are many related questions to this problem, but I have yet to come across a solution that's helped me. I'm relatively new to using the terminal, so any and all insight will be massively appreciated!
I have Python3.7 installed on my laptop (Mac M1). In my terminal, when I type
which python3 the output is,
/usr/bin/python3
When I type,
echo $PATH the output is,
”/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin:/usr/local/bin/python3
Finally, when I try,
python3 --version the output is,
python3: error: can't exec '/Applications/Xcode.app/Contents/Developer/usr/bin/python3' (errno=No such file or directory)
I'm very confused because the path in the error isn't in my $PATH.
As you have /usr/bin first in your path, when you just run python3, the shell will pick up /usr/bin/python3. Now, that’s not a real Python interpreter. You can tell that from the fact that its link count is 76. That means that it is one of 76 different names for the same program! These are “shims” that Apple install in /usr/bin, which just hand over control to various developer tools installed as part of Xcode. That is why, when you try to run it, you get an error message talking about Xcode.
I do not fully understand how those shims work, and why the supposedly-Xcode-installed Python is not available on your system, so I will not delve further into that. (My guess is that xcode-select figures somewhere in the answer...)
However, if you have installed Python manually in the /usr/local hierarchy, it might be a good idea to fix your PATH variable so that /usr/local/bin appears before /usr/bin. Theat way, then you run python3, you get the one you installed, not the Apple one.
Thanks to the information provided, I found a solution that works. The following PATH did the trick:
/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin

python has been installed (could be show in cmd) but can not run py file?

I am newbie with python and here is my problem. I installed python on my windows pc and as you can see on this picture, I checked it by the command python --version and it showed me the version, no problem.
But when I ran this very simple code:
my_text = "We made it!"
print(my_text)
It said to me that Python was not found! as you can see in the picture.
I searched on the internet, and add the path variable as they said in this guide:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings
but it still does not run.
Could you please give me some advise on how to solve this?
Try using python to run your .py file, like this
python test.py
If you are seeing instructions that say to use python3 to run Python scripts, it's probably because the author of those instructions uses a system environment where python is used for Python 2 and python3 is used for Python 3.
In your case on Windows, Python 3 was almost certainly installed using python as the command to run, so you should use python and not python3 to run your scripts.

Change Python:Run Python File in Terminal command in Visual Studio Code

I am using an anaconda environment in VS code when suddenly the Run Python File in Terminal command bound to the green play-button in the top right corner stopped working. It used to input: python_path file_path/file.py into the terminal and it worked perfectly fine.
But after running my code in the anaconda prompt program it has now changed to:
& conda run -n env_name python file_path/file.py and now I get a ModuleNotFoundError, that I don't have cv2 installed, which I do.
I can still run the code if I simply input: python file_path/file.py. My question is if it is possible to change the command that is bound to Run Python File in Terminal. I could not find a solution to this in a couple hours of searching. Thanks in advance.
One solution I found was to reinstall the older python plugin and the "conda run -n" command would not be used at runtime.
Reinstallation method, Extension --> Python--manage--> install another version
You're most likely running into a bug in conda 4.8. You can either downgrade the extension until a point release comes out with a fix or simply wait for a fix (hopefully Monday).

How to make pyInstaller work

Ok, so I have been through many of the different fixes, and I still can't get it to work. In python command line I run the
pip install pyinstaller
it gives me a syntax error, so I run the line of code to set my path, and pip is in my scripts, it still doesn't work. I am not sure how to get this to work. pip is installed but it still refuses to install pyinstaller, saying it has a syntax error. Upon looking this up I find you need to set the path, so I do so, but that does not fix the problem, Help would be very nice!
You have to run that command from the command line (the terminal), not the Python interpreter.
You may think if something is written in Python or for Python it must be run from the interpreter. Well, not necessarily. Speaking of pip or easy_install, they must be run from the terminal.

python Bad Interpreter error

I am trying to install Sublime Text 2 on my linux machine and I cannot figure out how to run the python script to install it. I am fairly new to linux and never programmed in python before. I am trying to run the python script PackageSetup.py using ./PackageSetup.py but i get the error:
bash: ./PackageSetup.py: python: bad interpreter: No such file or directory
not sure what I have to do. I have python on my machine. I can tell cause running 'python' puts me in the console.
For all I know this kind of issue can occur if you have a misspelling or mistake in the shebang. I see two ways to solve this issue: you can try to invoke PackageSetup.py via python, like python PackageSetup.py or you can open PackageSetup.py and try to find an issue in the shebang, maybe it needs to be a full path to python interpreter like /usr/bin/python not just python.
BTW, why don't you try to install it via some kind of package manager - there is a repo for debian-based distros, and I'm pretty sure that there have to be repositories for other distributives.

Categories