Error running MetaPhlAn4 - no_map error and sam file cannot be found

I am trying to run MetaPhlAn v4.0.0 but stumbled upon several errors.
This is the command I have used (the files have gone through quality check already):

metaphlan /PATH/TO/INPUT/kneaddata/main/${f}.fastq --input_type fastq --output_file /PATH/TO/OUTPUT/metaphlan/main/${f}_taxonomic_profile.tsv --samout /PATH/TO/OUTPUT/metaphlan/main/${f}_bowtie2.sam --nproc 50 --no_map --tmp_dir /PATH/TO/OUTPUT/metaphlan/main --bowtie2db=/PATH/TO/DB/metaphlan_db/v31 --index=mpa_vJan21_CHOCOPhlAnSGB_202103

Using the --no_map flag I got the error:

File “/PATH/miniconda3/envs/biobakery3.1/bin/metaphlan”, line 10, in
File “/PATH/miniconda3/envs/biobakery3.1/lib/python3.7/site-packages/metaphlan/”, line 993, in main
** pars[‘bowtie2out’] = tf.NamedTemporaryFile(dir=pars[‘tmp_dir’]).name**
File “/PATH/miniconda3/envs/biobakery3.1/lib/python3.7/”, line 547, in NamedTemporaryFile
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File “/PATH/miniconda3/envs/biobakery3.1/lib/python3.7/”, line 258, in _mkstemp_inner
fd =, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: ‘/PATH/TO/OUTPUT/metaphlan/main/tmpbicl7s5e’

This flag is used in MetaPhlAn3 and I didn’t stumble upon any error previously. I presumed that this flag is mainly for removing temp files. So I simply removed it and ran the command without it.

Yet I still got an error:

IOError: “[Errno 2] No such file or directory: ‘/PATH/TO/OUPTUT/metaphlan/main/${f}_bowtie2.sam’”

Why would it search for the .sam file? It’s like it skips the alignment step with bowtie2.

Edit - I think I solved it. I just had to create the designated path ><. I am used to working with anadama2 which creates folders automatically.