hisat2 /usr/bin/env: ‘python’: No such file or directory
1
0
Entering edit mode
6 weeks ago
Xiaoyun ▴ 10

Hi all,

I am really struggling with hisat2 recently and getting confused. I'm trying to run hisat2:

hisat2-build -p 2 genome.fa genome

This is my error:

/usr/bin/env: ‘python’: No such file or directory
process erroe hisat2 • 1.2k views
ADD COMMENT
1
Entering edit mode

How did you install hisat2? Using conda?

ADD REPLY
0
Entering edit mode

Please post the output from:

$ which python 
ADD REPLY
0
Entering edit mode
/usr/bin/which: no python in (/home/yun/Downloads/hisat2-2.2.0:/home/yun/Downloads/Trimmomatic-0.39:/home/yun/Downloads/FastQC:/home/yun/.local/bin:/home/yun/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
ADD REPLY
0
Entering edit mode

Rather surprising that you have no system python installed. As Mensur Dlakic already said below you will need to install python.

ADD REPLY
0
Entering edit mode

here is my result:

which python3
/usr/bin/python3

but hisat2-buildis read only, I can't edit it.

ADD REPLY
0
Entering edit mode

do you have root/sudo permissions on this system? if you have sudo permissions, try sudo ln -s /usr/bin/python3 /usr/bin/python. If you have root permissons, log in as root and then try ln -s /usr/bin/python3 /usr/bin/python. If you do not root/admin privileges and you are using bash shell. try this:

  1. In your home folder, there is a file named .bashrc
  2. Open it. If it doesn't exist, create a new file with name .bashrc (note that dot in the file name)
  3. Add alias python=/usr/bin/python3
  4. Save the file with new changes and exit the file (or close the file)
  5. In a terminal, navigate to your home folder and type . .bashrc and press enter button
  6. Then try running hisat-build function.

Let us know if this works. Please also note that copy/paste from web may introduce unwanted spaces and/or characters.

ADD REPLY
0
Entering edit mode

I don't think these suggestions are in the spirit of how Linux uses python which usually refers to v2. If the OP has sudo privileges, I think they should install python (v2-something).

These two solutions may work for this problem (assuming Hisat2 is OK with python3), but there is a good chance there will be a problem down the line where a program expecting python2 will be trying to run using python3. There is a solution further below that will use python3 without introducing a possible confusion in the system.

ADD REPLY
0
Entering edit mode
how Linux uses python which usually refers to v2.

Not true.

Ubuntu team proposal to make python 3 as default python version on ubuntu and debian is available here:

Old documentation: https://wiki.ubuntu.com/Python/3

Updated documentation: https://wiki.ubuntu.com/Python

Old documentation was written in 2014 and latest HISAT is released in 2020.

 down the line where a program expecting python2 will be trying to run using python3

may be, may be not. As far as I know, later versions of HISAT 2 supports python 3, which user is supposed to use. Here is the link for HISAT2 support for pyhon3 (HISAT 2.2.1 release 7/24/2020): (https://daehwankimlab.github.io/hisat2/). If you have any link to such documentation where down the lane, hisat2-build or other components of hisat2 requires python 2, please post here. To my understanding, hisat2 suite of tools moved to python3.

ADD REPLY
0
Entering edit mode

Not true based on what? I have Ubuntu 20.04, and here is what it gives for which python:

/usr/bin/python

Then:

/usr/bin/python -V
Python 2.7.18

I realize that python v2 has been phased out starting this year, but in a majority of computers in the world python under Linux still refers to v2.

I said where a program expecting python2 meaning any program, not specifically Hisat2. There are tons of scripts out there with #!/usr/bin/python as their first line that are expecting python v2 and will not work with v3.

It will be many years from now, when python v2 is completely phased out, before /usr/bin/python can be safely linked to python3 without worrying that will mess up many existing scripts.

ADD REPLY
0
Entering edit mode
Not true based on what?

Based on distro release notes (https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Python3_by_default) for 20.04. Copy/pasted : In 20.04 LTS, the python included in the base system is Python 3.8. Python 2.7 has been moved to universe and is not included by default in any new installs.

SO post saying the same: https://askubuntu.com/questions/1232812/whats-the-default-python-version-in-ubuntu-20-04.

Here is the link release manifest for said distro: https://old-releases.ubuntu.com/releases/20.04/ubuntu-20.04-desktop-amd64.manifest. There is no single entry for python 2 or python 2.7, where as python3.8 multiple entries.

Tool chain upgrades for 20.04 : glibc 2.31, OpenJDK 11, rustc 1.41, GCC 9.3, Python 3.8.2, ruby 2.7.0, php 7.4, perl 5.30, golang 1.13 (https://wiki.ubuntu.com/FocalFossa/ReleaseNotes?action=show&redirect=FocalFossa%2FReleaseNotes%2F20.04).

Most importantly, I am on impish and default python is not 2.

ADD REPLY
0
Entering edit mode

Everything you said above is true, but doesn't contradict what I said. New Ubuntu versions install python3 by default and do not install python2 - they are phasing out python2. However, they install python3 as /usr/bin/python3 and there is nothing installed as /usr/bin/python. This is most likely the case with our OP, who has python3 installed but not the /usr/bin/python entry.

The reason system doesn't link /usr/bin/python to python3 is exactly to avoid problems with scripts that have #!/usr/bin/python as their first line and are expecting python2. Linux developers know that a large number of scripts out there are in this category, which is why /usr/bin/python is missing in newer Linux distros even though python3 is installed. The only way to get the system to create /usr/bin/python, at least to my knowledge, is to install python2.

Now, one can always do what you are suggesting and make a symbolic link to python3. That may solve the immediate problem, but globally speaking I think is not the right thing to do and will at some point cause problems.

ADD REPLY
0
Entering edit mode

It did work. But after I input:

hisat2 -t -p 2 -x shiryn\ RNAseq\ data/reference/grch38_genome/grch38 -1 shiryn\ RNAseq\ data/trimmed\ data/ly1_paired_1.trim.fq.gz shiryn\ RNAseq\ data/trimmed\ data/ly1_paired_2.trim.fq.gz -S shiryn\ RNAseq\ data/alighed/ly1.sam

The erroe is

File "/home/yun/Downloads/hisat2-2.2.0/hisat2_read_statistics.py", line 182
    length_map = sorted(length_map.iteritems(), key=lambda (k,v):(v,k), reverse=True)
                                                           ^
SyntaxError: invalid syntax
Extra parameter(s) specified: "data/reference/grch38_genome/grch38", "shiryn", "RNAseq", "data/trimmed", "data/ly1_paired_2.trim.fq.gz", "RNAseq", "data/alighed/ly1.sam"
Overall time: 00:00:00
Error: Encountered internal HISAT2 exception (#1)
Command: /home/yun/Downloads/hisat2-2.2.0/hisat2-align-s --wrapper basic-0 -t -p 2 -x shiryn -S shiryn RNAseq data/reference/grch38_genome/grch38 shiryn RNAseq data/trimmed data/ly1_paired_2.trim.fq.gz RNAseq data/alighed/ly1.sam 
(ERR): hisat2-align exited with value 1
ADD REPLY
0
Entering edit mode

You are not helping us here. What is it that worked, because there are lots of suggestions above?

Are you referring to sudo ln -s /usr/bin/python3 /usr/bin/python as what worked? If so, it seems that you are using 2.2.0 of the program which is not the newest release, and may not support python3. If you made a link to python3 with /usr/bin/python, you are doing exactly what I argued with @cpad0112 not to be a good idea. In other words, you may be using python3 with a script that expects a python2 syntax, and that throws an error.

Like I suggested before, the cleanest solution most likely is to install python2 system-wide and to make sure that /usr/bin/python actually points to it.

ADD REPLY
0
Entering edit mode
6 weeks ago
Mensur Dlakic ★ 15k

This error means one of the two things: 1) you don't have a system-wide installation of python; 2) your have python installed but it is not in its standard directory (/usr/bin/python). To figure this out, type:

which python

This will tell you where your python is, or it will again say No such file or directory. If the latter happens, you need to install python. If the previous command gives you a different python location, say /bin/python, you need to copy that line and paste it as a first line in hisat2-build. First find where hisat2-build is:

which hisat2-build

Then open this file and instead of the first line being #!/usr/bin/env python, enter #!/bin/python.

ADD COMMENT
0
Entering edit mode

but after I run this command

which python

the output is

 /usr/bin/which: no python in (/home/yun/Downloads/hisat2-2.2.0:/home/yun/Downloads/Trimmomatic-0.39:/home/yun/Downloads/FastQC:/home/yun/.local/bin:/home/yun/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
ADD REPLY
0
Entering edit mode

here is my result:

which python3
/usr/bin/python3

but hisat2-buildis read only, I can't edit it.

ADD REPLY
0
Entering edit mode

You have two options, and both of them require admin privileges by you, or by someone who can make these changes for.

The first option is to install python (which is usually a synonym for python v2.7), and it should by default go into /usr/bin directory. After that hisat2-build will work without any modification.

Your second option is to try running hisat2-build with your existing python3 installation. Don't know if that will work, but it might. In that case you need to edit hisat2-build as administrator and replace #!/usr/bin/env python on the first line with /usr/bin/python3. To see whether this even have a chance of working, you can run hisat2-build like this:

python3 `/usr/local/bin/hisat2-build`

You can find the exact hisat2-build location with which command.

ADD REPLY
0
Entering edit mode

It helps me a lot. Thank you so much!

ADD REPLY

Login before adding your answer.

Traffic: 2286 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6