How To Make Bash Script Use A Particular Python Version For Executing A Python Script?
I have python 2.6 and python installed on my Freebsd box. I want my bash script to execute a particular python script using python2.6 interpreter. It is showing import error.... Un
Solution 1:
It is probably caused by the following.
Your script imports some third-party library which was compiled by an older python version.
To fix this, reinstall the up-to-date library.
Solution 2:
file.sh
result=`python ~/PythonScriptName.py`;
Solution 3:
Use the absolute path to the python version you want.
Solution 4:
In the first line of the script, mention the shebang(#!)
#!/usr/bin/env python# Your script here
The error you got due to mismatch of compilation interpreter and running interpreter.This usually occurs with a Python installation compiled with Unicode UCS2 support running modules compiled against a Python installation with Unicode UCS4 support (or vis versa).You need to recompile/reinstall the scipy installation with exact the Python interpreter used for running your code.
Post a Comment for "How To Make Bash Script Use A Particular Python Version For Executing A Python Script?"