简体   繁体   English

/ usr / bin / env:python2.6:没有这样的文件或目录错误

[英]/usr/bin/env: python2.6: No such file or directory error

I have python2.6, python2.7 and python3 in my /usr/lib/ 我的/usr/lib/有python2.6,python2.7和python3

I am trying to run a file which has line given below in it as its first line 我正在尝试运行一个文件,其中包含下面给出的行作为其第一行

#!/usr/bin/env python2.6

after trying to run it it gives me following error 尝试运行它后,它给了我以下错误

/usr/bin/env: python2.6: No such file or directory

my default version on python is 2.7. 我在python上的默认版本是2.7。

How I can run the file without changing the default version of python. 如何在不更改python的默认版本的情况下运行该文件。

I think you might be confused about the location of your python executables, versus the location of the lib site-packages. 我想你可能会对python可执行文件的位置以及lib站点包的位置感到困惑。

Your python site-packages should be here: 你的python站点包应该在这里:
/usr/lib/python2.6/site-packages /usr/lib/python2.6/site-packages

But your executables should probably be here: 但是你的可执行文件应该在这里:
/usr/bin 在/ usr / bin中

If you run this following command, it should tell you where it is currently finding the executables: 如果运行以下命令,它应该告诉您当前在哪里找到可执行文件:

which python
which python2.7
...

Your $PATH environment variable should contain paths that have executable files directly underneath. 您的$ PATH环境变量应包含直接包含可执行文件的路径。 ie $ echo $PATH $ echo $PATH
/usr/bin:/usr/local/bin:/home/aUser/bin

If your executable is in another location that is not in your path and you don't want to neccessarily add that location to your path, you can also just symlink it to somewhere normal.... 如果您的可执行文件位于不在您的路径中的另一个位置,并且您不希望将该位置添加到您的路径中,那么您也可以将其符号链接到正常的某个位置....

ln -s /path/to/executable /usr/bin/executable

Here is a trick to find all the executable files named python: 这是一个找到名为python的所有可执行文件的技巧:

find /usr -type f -name 'python*' -perm -a+x

This might help you locate python2.6 这可能会帮助您找到python2.6

你的$PATH需要python2.6

您可能想要创建2.7的别名为2.6

sudo ln -s /usr/bin/python2.7 /usr/bin/python2.6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM