"-bash: python2: command not found" on OS X - python

I'm trying to use this script to import my iTunes library to another program.
At the step where I enter python2 export_to_quod_libet.py, I'm getting an error message that says that the python2 command can't be found. I figured out through python -v that I definitely have Python 2.7 installed, so I'm really confused about this.
I did find a similar question being asked here, but the original poster was using Windows (whereas I'm using OS X El Capitan), so a lot of what was said at least didn't seem applicable to my situation.
Could someone tell me what I'm doing wrong, please?

Maybe you could try do define an alias. It seems that python2 is hardcoded somewhere in the script.
You could try (just an example):
alias python2="python2.7"
and then run the script -- hope that helps.
Kind regards,
Julian

I confirmed it works on macOS. I installed Python 2.7 and 3.5 using brew commands:
brew update
brew install python
brew install python3

Related

Installing python-socketio-client

Please excuse my lack of knowledge and poor terminology.
I am trying to get python-socketio-client running on my PI3B. It is used by some python code, not written by me, that takes selected data from Volumio3.x's API (under Buster), and passes it to my audio preamp controller to display it. The current Artist and Song Title.
It all worked on my PI2B with a version of Volumio 2.x under Jessie.
All my attempts to install python-socketio-client have errored.
I was wondering if I should install it with python3, and if so how?
Thanks
To install python packages usually you have to run pip install -m package-name
For Volumio if you check documentation (pyvolumio package) is this the one you are trying to use?
Only Python 3.7 and above are supported.
As you can see in: https://pypi.org/project/pyvolumio/

How do I use YCM after installing Anaconda?

Getting error: requires Vim compiled with Python (2.7.1+ or 3.4+) support.
It is installed with Python3. YCM was working great until installing Anaconda. To fix I tried adding this to my .vimrc:
let g:ycm_path_to_python_interpreter = '/usr/bin/python'
I have also referred to the YCM FAQ and tried adding this to my .ycm_extra_conf.py:
def Settings(**kwargs):
return {
'interpreter_path': '/path/to/anaconda/python'
}
However nothing has removed or changed the error.
I have recompiled with anaconda python and then redid it with normal python when that didn't work either. It seems from others who asked this question it does need to be compiled with non-anaconda python.
I have seen suggestions to remove the anaconda path from .bash_profile but doesn't that defeat the purpose of having Anaconda?
Any help would be greatly appreciated.
Solved the problem by commenting out the Anaconda path in my .bash_profile. 'which' python still points to Anaconda python, but YCM compiles and works again.
No idea why this approach works, but it does.
I couldn't compile Youcompleteme successfully, which really made me confused.
Finally I found that is caused by Anaconda. So I used the default version python to recompile it again.
$ /usr/bin/python ~/.vim/bundle/Youcompleteme/install.py
It works perfectly.

tensorflow pip install on windows > error " no perl script found in input"

im trying to install tensorflow on my computer. I have windows 10. Im doing CPU only pip install. When i paste this (pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl) command into my command prompt i get error message that says "no perl script found in input". What is the problem? is it referring to Perl programming language or something else? how is perl related to any of this? Thanks!!!
what python version installed in your environment ?
if it's 3.6 you can simply replace the -cp35-cp35m- become -cp36-cp36m-
I hope it'll help
I just ran into the "No Perl script found in input" error myself, in a different situation (as is, not trying to use pip).
The original poster has supplied a comment that answers the question he asked; he had two "pip"s in his path and the wrong one was before the right one. He either had to change the order of his path or supply a full pathname.
This helped me solve my problem; I was using the command line lwp-download to download a file and suddenly got this error. Running lwp-download.bat solved my problem.
If you experience the "No Perl script found in input" error, try running "where" and then your command; in my example "where lwp-download". If you have more than one file in your path with that name, try to be specific. In my case, add the ".bat"

Ubuntu, how do you remove all Python 3 but not 2

I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place:
iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7
Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7.
So the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?
Removing Python 3 was the worst thing I did since I recently moved to the world of Linux. It removed Firefox, my launcher and, as I read while trying to fix my problem, it may also remove your desktop and terminal! Finally fixed after a long daytime nightmare. Just don't remove Python 3. Keep it there!
If that happens to you, here is the fix:
https://askubuntu.com/q/384033/402539
https://askubuntu.com/q/810854/402539
EDIT: As pointed out in recent comments, this solution may BREAK your system.
You most likely don't want to remove python3.
Please refer to the other answers for possible solutions.
Outdated answer (not recommended)
sudo apt-get remove 'python3.*'
So I worked out at the end that you cannot uninstall 3.4 as it is default on Ubuntu.
All I did was simply remove Jupyter and then alias python=python2.7 and install all packages on Python 2.7 again.
Arguably, I can install virtualenv but me and my colleagues are only using 2.7. I am just going to be lazy in this case :)
First of all, don't try the following command as suggested by Germain above.
`sudo apt-get remove 'python3.*'`
In Ubuntu, many software depends upon Python3 so if you will execute this command it will remove all of them as it happened with me. I found following answer useful to recover it.
https://askubuntu.com/questions/810854/i-deleted-package-python3-on-ubuntu-and-i-have-lost-dashboard-terminal-and-un
If you want to use different python versions for different projects then create virtual environments it will be very useful. refer to the following link to create virtual environments.
Creating Virtual Environment also helps in using Tensorflow and Keras in Jupyter Notebook.
https://linoxide.com/linux-how-to/setup-python-virtual-environment-ubuntu/
neither try any above ways nor sudo apt autoremove python3 because it will remove all gnome based applications from your system including gnome-terminal. In case if you have done that mistake and left with kernal only than trysudo apt install gnome on kernal.
try to change your default python version instead removing it. you can do this through bashrc file or export path command.
Its simple
just try:
sudo apt-get remove python3.7 or the versions that you want to remove

ImportError: No module named argparse

I am trying to run a Python program but get the error
ImportError: No module named argparse
I found the question “argparse Python modules in cli” here on StackOverflow and tried the first comment, i.e. running the command
python -c "import argparse; print argparse"
which resulted in
<module 'argparse' from '/usr/lib/python2.7/argparse.pyc'>
For me it seems like there is Python 2.7 installed on the machine (of which I am not administrator) and the argparse module is present as well. So I wonder why the module is not found. On another machine the script runs as it should. In the post referred to above, there is the comment that maybe sys.path is broken. I have no clue what that means, or how I can change its value. Any ideas?
Try installing argparse:
easy_install argparse
On CentOS I solved this with yum install python-argparse.
HT to LVA for the correct package name.
On a Debian system you can use the following command to install the argparse package:
sudo apt-get install python-argparse
You're probably using a different version of Python with your script than the one you execute in command line. Make sure that the script is using this interpretor: /usr/lib/python2.7. This installation has argparse for sure, as you proved it with the import on your first post.
Why your script can use a different Python installation? It can be the result of a Shebang line of the first line of your script that could pointed to a different Python interpretor which doesn't have the argparse module installed.
EDIT: Another problem can be that your script clean the sys.path list, and it would be very bad because every modules pre-installed wouldn't be accessible...
You don't have the module installed to the correct version of python.There is one of two ways you can fix this
Reinstall python and the module
Change python paths are demonstrated at one of these links (osx, windows(You shouldn't have to do this on windows I selected xp because that is what I run),linux
One of these should work but if it doesn't try rebooting. GOOD LUCK!! :)
If your source file has the same name with argparse, and you put it in the current directory with your scripts, you may encountered the problem.
Run this command: yum install -y python-argparse. It can fix it when you are CentOS.

Categories

Resources