# MetaPhlAn 2 UnboundLocalError

**URL:** <https://forum.biobakery.org/t/metaphlan-2-unboundlocalerror/4148>\
**Category:** MetaPhlAn\
**Created:** [October 2, 2022, 9:36am UTC](https://forum.biobakery.org/t/metaphlan-2-unboundlocalerror/4148 "2022-10-02T09:36:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ijenn](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ijenn/32/1691_2.png) [@Ijenn](https://forum.biobakery.org/u/Ijenn)\
**Post date:** [October 2, 2022, 9:36am UTC](https://forum.biobakery.org/t/metaphlan-2-unboundlocalerror/4148/1 "2022-10-02T09:36:18Z")

</div>

Hello,  
Excuse me, I got an issue when using MetaPhlAn 2.0:

> > step1  
> > I’ve followed the instruction to install( [[metaphlan2 · biobakery/biobakery Wiki · GitHub](https://github.com/biobakery/biobakery/wiki/metaphlan2)] ), though when I ran:  
> > $ metaphlan2.py \<input\_fasta\> --input\_type fasta \> \<output\_name\>  
> > the partial **error** message came like that:

```auto
  File "/newdisk1/ijenn/BadouziProject/Preparation/MIMOSA/proceMetagenomic/download/MetaPhlAn-2.8/metaphlan2.py", line 836, in check_and_install_database
    download_unpack_tar(FILE_LIST, index, bowtie2_db, bowtie2_build, nproc)
  File "/newdisk1/ijenn/BadouziProject/Preparation/MIMOSA/proceMetagenomic/download/MetaPhlAn-2.8/metaphlan2.py", line 745, in download_unpack_tar
    url_tar_file = ls_f["mpa_" + download_file_name + ".tar"]
UnboundLocalError: local variable 'ls_f' referenced before assignment

```

My assumption is that “metaphlan2.py” couldn’t find my “mpa\_…”file.

> > Step2.  
> > So I’ve searched for the files (  
> > [[MetaPhlAn 3](https://zenodo.org/record/3957592#.YzlU9W4zbCl)] or [[Index of /databases/MetaPhlAn/metaphlan\_databases](http://cmprod1.cibio.unitn.it/databases/MetaPhlAn/metaphlan_databases/) ])and placed into the “metaphlan\_databases folder”  
> > , then I ran:  
> > $ metaphlan2.py \<input\_fasta\> --input\_type fasta -x MetaPhlAn-2.8/metaphlan\_databases/mpa\_v30\_CHOCOPhlAn\_201901 --bowtie2db MetaPhlAn-2.8/metaphlan\_databases/ \> \<output\_name\>  
> > Though the **same error** came:

```auto
"/newdisk1/ijenn/BadouziProject/Preparation/MIMOSA/proceMetagenomic/download/MetaPhlAn-2.8/metaphlan2.py", line 745, in download_unpack_tar
    url_tar_file = ls_f["mpa_" + download_file_name + ".tar"]
UnboundLocalError: local variable 'ls_f' referenced before assignment

```

I have no idea left to solve this, hoping someone could help me with that.  
Thank you so much.  
Regards,  
Ijenn

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [October 5, 2022, 1:04pm UTC](https://forum.biobakery.org/t/metaphlan-2-unboundlocalerror/4148/2 "2022-10-05T13:04:06Z")

</div>

Hi @Ijenn  
The MetaPhlAn 3.0 marker database is not compatible using metaphlan2. Please, upgrate the metaphlan version to 3 (or even to version 4) or instead use the old mpa\_v20 database ([Index of /biobakery3/metaphlan\_databases](http://cmprod1.cibio.unitn.it/biobakery3/metaphlan_databases/))

---

<div class="post-metadata">

**Author:** ![Ijenn](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ijenn/32/1691_2.png) [@Ijenn](https://forum.biobakery.org/u/Ijenn)\
**Post date:** [October 8, 2022, 2:38am UTC](https://forum.biobakery.org/t/metaphlan-2-unboundlocalerror/4148/3 "2022-10-08T02:38:49Z")

</div>

Hi,  
Thanks for your reply!  
Eventually I found out that it’s the coding of the database download site in metaphlan.py have to be changed, because the original file is empty[[Dropbox - File Deleted](https://www.dropbox.com/sh/7qze7m7g9fe2xjg/AADHWzATSQcI0CNFD0sk7MAga)]. In that case, I will try your way to upgrade to version4.

Regards,
