ubuntu linux gmsh gives "sh: 1: python: not found" error - python

I try to run a Gmsh python script from the command line (or from PyCharm or Spyder)
gmsh script.py
but I get the following error:
sh: 1: python: not found
also in the Gmsh console there is this error:
Done - 1 error : Abnormal server termination (Socket listening timeout on socket /home/user/.gmshsock2)
I did check python3 version which looks fine:
$ python3 --version
Python 3.10.4
What could be the problem?
Can anyone help to solve this ?
Thanks
Oli

The problem might be that Python is installed on your system, but that there is no symlink from python3 to python. Therefore python3 is a valid command and confirms that python is installed, but the command python is no available.
As you tagged ubuntu, i would suggest you to install the package python-is-python3 with the following command
sudo apt install python-is-python3
This package will create a symlink from /usr/bin/python to /usr/bin/python3, and therefore gmsh can execute the command python.

Related

exec: "python": executable file not found in $PATH

since the last update to Mac OS Monterey 12.3 I get the following error message when compiling my Arduino sketch:
exec: "python": executable file not found in $PATH
Unfortunately, I have not yet been able to find out how to solve this problem.
I would be very grateful for ideas and suggestions.
Four steps are needed:
Install python3 using i.e. Brew:
brew install python
python3 is in:
/opt/homebrew/bin/python3
Link Python to python3:
sudo ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python
Check if you can execute it from the terminal; i.e.,
python --version
Irrespective of whether you use python --version or python3 --version, it should show python 3 now.
Open terminal and execute:
open /Applications/Arduino.app
It works in my case. It looks like when Arduino is executed from the GUI, it does not read the $PATH properly, so although python is linked to python3, it does not find it.
Problem
In MacOS 12.3 Apple removed python2.7 (python) from MacOS.
Solution
What I did to solve this is link python3 to python, I wouldn't recommend it because it's sus, I would recommend you wait until Arduino IDE fixes this issue in a later build. For the time being, you could try their Web IDE: Arduino Editor
However, here are the instructions to link python3 to python:
If you don't have python3 installed, install it here in the link below:
Python Install Page
Find your path for the current version of python3 you're using
which python3
it'll show up with something like this:
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
Copy that and use it to run this command that links python 3 to python. Replace the first file path with where your python3 is.
ln -s -f INSERT_PATH_OF_PYTHON3 /usr/local/bin/python
for example:
ln -s -f /Library/Frameworks/Python.framework/Versions/3.10/bin/python3 /usr/local/bin/python

AWS Elastic Beanstalk CLI Using Wrong Python Version

I'm on a Mac OSX (Catalina) trying to install the AWS Elastic Beanstalk CLI.
>>>python --version
Python 2.7.16
>>>which python
/usr/bin/python
>>>python3 --version
Python 3.7.5
>>>which python3
/usr/local/bin/python3
What I've tried
Using Brew
>>>brew uninstall awsebcli
>>>brew install awsebcli
>>>eb --version
-bash: /Users/<user>/.local/bin/eb: /Users/<user>/projects/hello-world-flask/venv/bin/python3: bad interpreter: No such file or directory
Now the funny thing is that hello-world-flask is just a toy example I have in one of my directories, but I have no idea why the EB CLI is trying to use that venv, or why it says that it doesn't exist.
>>>ls /Users/<user>/projects/hello-world-flask/venv/bin/python3
/Users/<user>/projects/hello-world-flask/venv/bin/python3
Using Pip3
>>>brew uninstall awsebcli
>>>pip3 install awsebcli
...
Successfully installed awsebcli-3.16.0
>>>eb --version
-bash: /Users/<user>/.local/bin/eb: /Users/<user>/projects/hello-world-flask/venv/bin/python3: bad interpreter: No such file or directory
The Question
I'm assuming the EB CLI is just supposed to execute Python 3.x. How do I fix this and make the EB CLI use the correct version of Python?
I realize this answer is a bit late and ran into a similar issue myself. According to this you might have better luck being explicit about your python executable and using the --python-installation flag. Try something like
python scripts/ebcli_installer.py --python-installation /path/to/some/python/on/your/computer
or to be extra explicit
/path/to/your/exact/python scripts/ebcli_installer.py --python-installation /path/to/some/python/on/your/computer
This is part of the "Advanced Use" section on the EB CLI github
I couldn't figure this out. I keep encountering error env: python: No such file or directory. So I just defaulted to installing it via brew https://formulae.brew.sh/formula/aws-elasticbeanstalk#default

ImportError on ArchLinux ARM

I've made a python program that goes online and look for news on some site and if something is found it send me a message on Telegram. I've run my program on my Debian machine and it works, now I want put it on my Raspberry Pi and let it run... So I copieted all the file on my raspberry installed all the necessary library (included https://github.com/eternnoir/pyTelegramBotAPI) but when I run my program with :
python2 ./main.py
I get:
ImportError: No module named telebot
What I can do? and why I get this error?
EDIT:
Probably the error is what Bruno9779 said. Those are my output:
python2 --version ----> python 2.7.11
python --version ----> python 3.5.1
env python --version -> python 3.5.1
pip --version --------> pip 2.7.1.2 from /usr/lib/python3.5/site_packages (python 3.5)
So I changed my shebang to #!/usr/bin/python2 -tt
(I've also tried with #!/usr/bin/env python2 -tt but I still get the same error)
From what surfaced in the comments of my other answer, it looks like there could be a versión mismatch of sorts.
Try:
python2 --version
python --version
env python --version
pip --version
To see if there are mismatches.
Since you are calling the script with the command python2 I guess you are running some sort of virtualenv, where python or python3 point to another version of python.
The versión of pip you use to install packages must be the same as the version you use to run the script
Install telebot with pip:
pip install telebot
It could be in the AUR, but I am not on Arch now to check

Howto enable rpy2 in python using ports?

I know that there are several questions touching this problem, but I can hardly figure out, if there is one solution for my problem. I am using Mac 10.6.8, MacPorts 2.1.3.
Here I refer to one discussion here on SO, where my issue seems to be addressed. This is, what I have done:
$ sudo port install py-rpy2 # seemed to be fine. A
$ python -m 'rpy2.tests' # gave the output
usr/bin/python: No module named rpy2
$ /opt/local/bin/python2.7 -m 'rpy2.tests # results in a
'Segmentation fault' # and MacOS is complaining..
After upgrading all outdated packages and
$ sudo port -f uninstall py-rpy2
$ sudo port -f install py-rpy2
... the same as above.<br>
$ sudo easy_install rpy2
throws many errors and ends with
'error: Setup script exited with error: command 'gcc-4.2' failed with exit status 1'
You can find full output here.
I have only a
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/
path, 2.7 has no
/Library/Frameworks/Python.framework/Versions/
entry.
localhost:~$ ls /opt/local/bin/python*
/opt/local/bin/python2.4
/opt/local/bin/python3.3 /opt/local/bin/python2.6
/opt/local/bin/python3.3-config /opt/local/bin/python2.6-config
/opt/local/bin/pythonw2.6 /opt/local/bin/python2.7
/opt/local/bin/pythonw2.7 /opt/local/bin/python2.7-config
/opt/local/bin/pythonw3.3
$ which python
'/usr/bin/python'
This one is Python 2.6.1.

Getting Fabric Python Library to Work

I installed Fabric via Pip, which was installed via Homebrew (OS X 10.6.6). The Fabric library is where pip says it should be, however I cannot get a basic fabfile going.
I've tried the simple hello world example found here: http://docs.fabfile.org/en/1.0.1/tutorial.html
Bash gives me the following error when I try fab hello:
-bash: fab: command not found
Paths:
Python 2.7.1: /usr/local/bin/python
pip libraries: /usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages
I'm probably overlooking something silly. Thanks for the help.
When you install Fabric with Homebrew and Pip, fab gets put at /usr/local/Cellar/python/2.7.1/bin/fab. Make sure /usr/local/Cellar/python/2.7.1/bin is on your PATH.

Categories

Resources