error when running kleborate: 'module' object has no attribute 'TemporaryDirectory'
Closed this issue · 3 comments
Dear all,
I am trying to use Kleborate, but while running your test commands (https://github.com/katholt/Kleborate#test-commands), I keep on getting the following output:
strain species ST virulence_score resistance_score Yersiniabactin YbST Colibactin CbST Aerobactin AbST Salmochelin SmST rmpA rmpA2 wzi K_locus K_locus_confidence O_locus O_locus_confidence AGly Col Fcyn Flq Gly MLS Ntmdz Phe Rif Sul Tet Tgc Tmt Omp Bla Bla_Carb Bla_ESBL Bla_ESBL_inhR Bla_broad Bla_broad_inhR
Traceback (most recent call last):
File "/usr/local/bin/kleborate", line 11, in <module>
load_entry_point('Kleborate==0.4.0b0', 'console_scripts', 'kleborate')()
File "/usr/local/lib/python2.7/dist-packages/kleborate/kleborate.py", line 44, in main
with tempfile.TemporaryDirectory() as tmp_dir:
AttributeError: 'module' object has no attribute 'TemporaryDirectory'
I installed all the dependencies in a conda environment, which has the following packages (output of conda list
):
# packages in environment at /software/miniconda3/envs/kleborate_102020:
#
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 1_gnu conda-forge
biopython 1.70 np112py36_1 bioconda
blas 1.1 openblas conda-forge
blast 2.7.1 h4422958_6 bioconda
boost 1.67.0 py36_4
boost-cpp 1.64.0 1 conda-forge
bzip2 1.0.8 h516909a_3 conda-forge
c-ares 1.16.1 h516909a_3 conda-forge
ca-certificates 2020.7.22 0 anaconda
capnproto 0.6.1 hfc679d8_1 conda-forge
certifi 2020.6.20 py36_0 anaconda
curl 7.71.1 he644dc0_8 conda-forge
entrez-direct 13.9 pl526h375a9b1_0 bioconda
expat 2.2.9 he1b5a44_2 conda-forge
freetype 2.10.2 he06d7ca_0 conda-forge
gmp 6.1.2 hf484d3e_1000 conda-forge
gnutls 3.5.19 h2a4e5f8_1 conda-forge
gsl 2.6 h294904e_0 conda-forge
icu 58.2 hf484d3e_1000 conda-forge
jpeg 9d h516909a_0 conda-forge
krb5 1.17.1 hfafb76e_3 conda-forge
lcms2 2.11 hbd6801e_0 conda-forge
ld_impl_linux-64 2.35 h769bd43_9 conda-forge
libblas 3.8.0 17_openblas conda-forge
libboost 1.67.0 h46d08c1_4
libcblas 3.8.0 17_openblas conda-forge
libcurl 7.71.1 hcdd3856_8 conda-forge
libedit 3.1.20191231 he28a2e2_2 conda-forge
libev 4.33 h516909a_1 conda-forge
libffi 3.2.1 he1b5a44_1007 conda-forge
libgcc 7.2.0 h69d50b8_2 conda-forge
libgcc-ng 9.3.0 h5dbcf3e_17 conda-forge
libgfortran-ng 7.5.0 hae1eefd_17 conda-forge
libgfortran4 7.5.0 hae1eefd_17 conda-forge
libgomp 9.3.0 h5dbcf3e_17 conda-forge
libnghttp2 1.41.0 h8cfc5f6_2 conda-forge
libopenblas 0.3.10 h5a2b251_0
libpng 1.6.37 hed695b0_2 conda-forge
libssh2 1.9.0 hab1572f_5 conda-forge
libstdcxx-ng 9.3.0 h2ae2ef3_17 conda-forge
libtiff 4.1.0 hc7e4089_6 conda-forge
libwebp-base 1.1.0 h516909a_3 conda-forge
lz4-c 1.9.2 he1b5a44_3 conda-forge
mash 2.2.2 ha61e061_2 bioconda
mmtf-python 1.1.2 py_0 conda-forge
msgpack-python 1.0.0 py36hdb11119_1 conda-forge
ncurses 6.2 he1b5a44_1 conda-forge
nettle 3.3 0 conda-forge
numpy 1.12.1 py36_blas_openblash1522bff_1001 [blas_openblas] conda-forge
olefile 0.46 py_0 conda-forge
openblas 0.3.3 h9ac9557_1001 conda-forge
openssl 1.1.1h h7b6447c_0 anaconda
pcre 8.44 he1b5a44_0 conda-forge
perl 5.26.2 h516909a_1006 conda-forge
perl-app-cpanminus 1.7044 pl526_1 bioconda
perl-archive-tar 2.32 pl526_0 bioconda
perl-base 2.23 pl526_1 bioconda
perl-business-isbn 3.004 pl526_0 bioconda
perl-business-isbn-data 20140910.003 pl526_0 bioconda
perl-carp 1.38 pl526_3 bioconda
perl-common-sense 3.74 pl526_2 bioconda
perl-compress-raw-bzip2 2.087 pl526he1b5a44_0 bioconda
perl-compress-raw-zlib 2.087 pl526hc9558a2_0 bioconda
perl-constant 1.33 pl526_1 bioconda
perl-data-dumper 2.173 pl526_0 bioconda
perl-digest-hmac 1.03 pl526_3 bioconda
perl-digest-md5 2.55 pl526_0 bioconda
perl-encode 2.88 pl526_1 bioconda
perl-encode-locale 1.05 pl526_6 bioconda
perl-exporter 5.72 pl526_1 bioconda
perl-exporter-tiny 1.002001 pl526_0 bioconda
perl-extutils-makemaker 7.36 pl526_1 bioconda
perl-file-listing 6.04 pl526_1 bioconda
perl-file-path 2.16 pl526_0 bioconda
perl-file-temp 0.2304 pl526_2 bioconda
perl-html-parser 3.72 pl526h6bb024c_5 bioconda
perl-html-tagset 3.20 pl526_3 bioconda
perl-html-tree 5.07 pl526_1 bioconda
perl-http-cookies 6.04 pl526_0 bioconda
perl-http-daemon 6.01 pl526_1 bioconda
perl-http-date 6.02 pl526_3 bioconda
perl-http-message 6.18 pl526_0 bioconda
perl-http-negotiate 6.01 pl526_3 bioconda
perl-io-compress 2.087 pl526he1b5a44_0 bioconda
perl-io-html 1.001 pl526_2 bioconda
perl-io-socket-ssl 2.066 pl526_0 bioconda
perl-io-zlib 1.10 pl526_2 bioconda
perl-json 4.02 pl526_0 bioconda
perl-json-xs 2.34 pl526h6bb024c_3 bioconda
perl-libwww-perl 6.39 pl526_0 bioconda
perl-list-moreutils 0.428 pl526_1 bioconda
perl-list-moreutils-xs 0.428 pl526_0 bioconda
perl-lwp-mediatypes 6.04 pl526_0 bioconda
perl-lwp-protocol-https 6.07 pl526_4 bioconda
perl-mime-base64 3.15 pl526_1 bioconda
perl-mozilla-ca 20180117 pl526_1 bioconda
perl-net-http 6.19 pl526_0 bioconda
perl-net-ssleay 1.88 pl526h90d6eec_0 bioconda
perl-ntlm 1.09 pl526_4 bioconda
perl-parent 0.236 pl526_1 bioconda
perl-pathtools 3.75 pl526h14c3975_1 bioconda
perl-scalar-list-utils 1.52 pl526h516909a_0 bioconda
perl-socket 2.027 pl526_1 bioconda
perl-storable 3.15 pl526h14c3975_0 bioconda
perl-test-requiresinternet 0.05 pl526_0 bioconda
perl-time-local 1.28 pl526_1 bioconda
perl-try-tiny 0.30 pl526_1 bioconda
perl-types-serialiser 1.0 pl526_2 bioconda
perl-uri 1.76 pl526_0 bioconda
perl-www-robotrules 6.02 pl526_3 bioconda
perl-xml-namespacesupport 1.12 pl526_0 bioconda
perl-xml-parser 2.44_01 pl526ha1d75be_1002 conda-forge
perl-xml-sax 1.02 pl526_0 bioconda
perl-xml-sax-base 1.09 pl526_0 bioconda
perl-xml-sax-expat 0.51 pl526_3 bioconda
perl-xml-simple 2.25 pl526_1 bioconda
perl-xsloader 0.24 pl526_0 bioconda
pillow 7.2.0 py36h8328e55_1 conda-forge
pip 20.2.3 py_0 conda-forge
py-boost 1.67.0 py36h04863e7_4
python 3.6.11 h4d41432_2_cpython conda-forge
python_abi 3.6 1_cp36m conda-forge
readline 8.0 he28a2e2_2 conda-forge
reportlab 3.5.51 py36hcce1d1f_0 conda-forge
setuptools 50.3.0 py36hb0f4dca_1 anaconda
sqlite 3.33.0 h4cf870e_1 conda-forge
tk 8.6.10 hed695b0_1 conda-forge
wheel 0.35.1 pyh9f0ad1d_0 conda-forge
xz 5.2.5 h516909a_1 conda-forge
zlib 1.2.11 h516909a_1009 conda-forge
zstd 1.4.5 h6597ccf_2 conda-forge
At first, I thought the error might be an issue with my python version, but I have python 3.6 in this environment. So not sure what is causing this.
Thanks for any help
I just realised Kleborate has a conda package. I just tried to install it as a new environment. When I ran it I got the following error:
/home/rramiro/.local/lib/python3.6/site-packages/Bio/SubsMat/__init__.py:131: BiopythonDeprecationWarning: Bio.SubsMat has been deprecated, and we intend to remove it in a future release of Biopython. As an alternative, please consider using Bio.Align.substitution_matrices as a replacement, and contact the Biopython developers if you still need the Bio.SubsMat module.
BiopythonDeprecationWarning,
Traceback (most recent call last):
File "/software/miniconda3/envs/kleborate_09102020/bin/kleborate", line 7, in <module>
from kleborate.kleborate import main
File "/software/miniconda3/envs/kleborate_09102020/lib/python3.6/site-packages/kleborate/kleborate.py", line 28, in <module>
from .resBLAST import read_class_file, get_res_headers, resblast_one_assembly
File "/software/miniconda3/envs/kleborate_09102020/lib/python3.6/site-packages/kleborate/resBLAST.py", line 25, in <module>
from .truncation import truncation_check
File "/software/miniconda3/envs/kleborate_09102020/lib/python3.6/site-packages/kleborate/truncation.py", line 16, in <module>
from Bio.Alphabet import IUPAC
File "/home/rramiro/.local/lib/python3.6/site-packages/Bio/Alphabet/__init__.py", line 21, in <module>
"Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the ``molecule_type`` as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information."
ImportError: Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the ``molecule_type`` as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information.
(kleborate_09102020) rramiro@bioinfo001:~$ conda deactivate kleborate_09102020
deactivate does not accept arguments
remainder_args: ['kleborate_09102020']
I could overcome this by downgrading Biopython from version 1.78 to 1.77 (see https://biopython.org/wiki/Alphabet). However, I then get the following error:
Error: could not find Kaptive directory. Did you git clone with --recursive?
, even if I run Kleborate without it needing to use Kaptive and even after installing the Kaptive package in the same conda environment.
Hi ramiroricardo,
We've just released a new version fo Kleborate (v2.0.0) that includes a fix for compatibility with the latest version fo Biopython if you'd like to give that a go. We love conda but we didn't create the conda environment for Kleborate so unfortunately can't make specific fixes there.
Thanks,
Kelly
The original error ('module' object has no attribute 'TemporaryDirectory'
) was caused by the fact that you were running Kleborate through Python v2.7, while it needs v3.6 or later.
As Kelly said, the new version will hopefully straighten things out, so I'll close this issue now. But feel free to open a new issue if you're still having problems!
Ryan