mamba
mamba copied to clipboard
AttributeError: module 'libmambapy' has no attribute 'QueryFormat'
I just installed mamba in an existing miniconda base
environment (created a while ago) and tried to use it to create a new environment, but I get the following error. Some googling didn't turn up previous reports so far.
I'm on Windows 10 (21H1 build 19043.1415).
Tried with mamba 0.19.1
(the one that got installed after conda install mamba -c conda-forge
), then tried downgrading to 0.18.1
since that one is the last release according to the GitHub project.
(base) PS D:\Zertrin\xxxx\xxxx\xxxx\xxxx> mamba env create -n mambatest
Traceback (most recent call last):
File "C:\Users\Zertrin\Miniconda3\Scripts\mamba-script.py", line 6, in <module>
from mamba.mamba import main
File "C:\Users\Zertrin\Miniconda3\lib\site-packages\mamba\mamba.py", line 50, in <module>
from mamba import repoquery as repoquery_api
File "C:\Users\Zertrin\Miniconda3\lib\site-packages\mamba\repoquery.py", line 12, in <module>
def _repoquery(query_type, q, pool, fmt=api.QueryFormat.JSON):
AttributeError: module 'libmambapy' has no attribute 'QueryFormat'
Here is the content of the base environment so far:
(base) PS D:\Zertrin\xxxx\xxxx\xxxx\xxxx> conda list
# packages in environment at C:\Users\Zertrin\Miniconda3:
#
# Name Version Build Channel
brotlipy 0.7.0 py37hcc03f2d_1003 conda-forge
bzip2 1.0.8 h8ffe710_4 conda-forge
ca-certificates 2021.10.8 h5b45459_0 conda-forge
certifi 2021.10.8 py37h03978a9_1 conda-forge
cffi 1.15.0 py37hd8e9650_0 conda-forge
charset-normalizer 2.0.9 pyhd8ed1ab_0 conda-forge
colorama 0.4.4 pyh9f0ad1d_0 conda-forge
conda 4.11.0 py37h03978a9_0 conda-forge
conda-package-handling 1.7.3 py37ha54c9ec_1 conda-forge
console_shortcut 0.1.1 3
cryptography 36.0.1 py37h65266a2_0 conda-forge
flake8 3.6.0 py37_0
idna 3.1 pyhd3deb0d_0 conda-forge
krb5 1.19.2 h20d022d_3 conda-forge
libarchive 3.5.2 hb45042f_1 conda-forge
libcurl 7.80.0 h789b8ee_1 conda-forge
libiconv 1.16 he774522_0 conda-forge
libmamba 0.19.1 h44daa3b_0 conda-forge
libmambapy 0.19.1 py37ha07342c_0 conda-forge
libsolv 0.7.19 h7755175_5 conda-forge
libssh2 1.10.0 h680486a_2 conda-forge
libxml2 2.9.12 hf5bbc77_1 conda-forge
libzlib 1.2.11 h8ffe710_1013 conda-forge
lz4-c 1.9.3 h8ffe710_1 conda-forge
lzo 2.10 he774522_1000 conda-forge
mamba 0.19.1 py37h13f6ddf_0 conda-forge
mccabe 0.6.1 py_1 conda-forge
menuinst 1.4.18 py37h03978a9_1 conda-forge
openssl 1.1.1l h8ffe710_0 conda-forge
pip 21.3.1 pyhd8ed1ab_0 conda-forge
pybind11-abi 4 hd8ed1ab_3 conda-forge
pycodestyle 2.4.0 py37_0
pycosat 0.6.3 py37hcc03f2d_1009 conda-forge
pycparser 2.21 pyhd8ed1ab_0 conda-forge
pyflakes 2.0.0 py37_0
pyopenssl 21.0.0 pyhd8ed1ab_0 conda-forge
pysocks 1.7.1 py37h03978a9_4 conda-forge
python 3.7.1 h9460c21_1003 conda-forge
python_abi 3.7 2_cp37m conda-forge
pywin32 303 py37hcc03f2d_0 conda-forge
reproc 14.2.3 h8ffe710_0 conda-forge
reproc-cpp 14.2.3 h0e60522_0 conda-forge
requests 2.26.0 pyhd8ed1ab_1 conda-forge
ruamel_yaml 0.15.80 py37hcc03f2d_1006 conda-forge
setuptools 60.2.0 py37h03978a9_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
tk 8.6.11 h8ffe710_1 conda-forge
tqdm 4.62.3 pyhd8ed1ab_0 conda-forge
ucrt 10.0.20348.0 h57928b3_0 conda-forge
urllib3 1.26.7 pyhd8ed1ab_0 conda-forge
vc 14.2 hb210afc_5 conda-forge
vs2015_runtime 14.29.30037 h902a5da_5 conda-forge
wheel 0.37.1 pyhd8ed1ab_0 conda-forge
win_inet_pton 1.1.0 py37h03978a9_3 conda-forge
xz 5.2.5 h62dcd97_1 conda-forge
yaml 0.2.5 h8ffe710_2 conda-forge
yaml-cpp 0.6.3 ha925a31_4 conda-forge
zlib 1.2.11 h8ffe710_1013 conda-forge
zstd 1.5.1 h6255e5f_0 conda-forge
Any idea?
I guess no access to specific mamba libraries. I have this error if run ...\Scripts\mamba.exe from an usual cmd prompt. And no errors if run ...\condabin\mamba.bat
Official command promt for mambaforge has several entries for "mamba" in PATH:
(base) C:\Users\...>where mamba
C:\a\python\Library\bin\mamba.bat
C:\a\python\Scripts\mamba.exe
C:\a\python\condabin\mamba.bat
The first entry runs:
@CALL "%~dp0..\..\condabin\mamba.bat" %*
In "...\condabin\mamba.bat" there is expansion of PATH: (Try to search the libraries there...)
@SET PATH=!_sysp!;!_sysp!\Library\mingw-w64\bin;!_sysp!\Library\usr\bin;!_sysp!\Library\bin;!_sysp!\Scripts;!_sysp!\bin;%PATH%
I'm also seeing this, investigating today.
Can confirm that this is due to the shared object file not being found (on Windows, the .pyd
file)
What would the environment variable that's set incorrectly in that case?
it sounds a lot like the PATH
variable isn't properly set. Is this happening in powershell
or cmd.exe
?
It doesn't seem to have anything to do with PATH
because this works:
set PATH=X
set LIB=X
C:\Users\j\mambaforge\condabin\mamba
OK, one thing that is really odd is that the libmambapy
package contains multiple cp3XX-...pyd
files. We're not cleaning up properly between the different outputs in our conda meta.yaml.
However, I don't know if this is related to this failure here. What python
version are you using?
I'm still not entirely sure what's going on here, this is from a CI pipeline with limited debugability. Python version in environment.yml
is 3.8.
$ python --version
Python 3.7.9
$ C:\Miniconda\condabin\mamba.bat info (also: C:\Miniconda\Library\bin\mamba.bat)
...
python version : 3.9.5.final.0
...
$ C:\Miniconda\Scripts\mamba.exe info
...
AttributeError: module 'libmambapy' has no attribute 'QueryFormat'
...
Does it mean that for some reason, Pythonn 3.7 is used to execute mamba.exe
whereas mamba.bat
uses the correct version of the interpreter (3.9)?
Yeah that's exactly the problem when you use the mamba.exe directly -- then the %PATH% is not properly set up and the dlls are not found.
The mamba.bat file does add the necessary directories to the %PATH% to make it work
I wonder why it's only a problem on Windows. Where can I find the mamba.exe
source code?
I had the same problem and miniconda reinstallation solved it. Not quite innovative and profound solution but it worked. Seems like some broken dependencies in existing base environment.
Where can I find the mamba.exe source code?
ping @wolfv
Hey, sorry @jonashaag for the slow response. I am quite sure the mamba.exe
file is autogenerated by setuptools from the entrypoints: https://github.com/mamba-org/mamba/blob/99c3485dae05fd1b5f2d78f42e3151987f9cad7a/mamba/setup.py#L41
Yeah that's exactly the problem when you use the mamba.exe directly -- then the %PATH% is not properly set up and the dlls are not found.
The mamba.bat file does add the necessary directories to the %PATH% to make it work
I am also facing the same problem on windows
mamba.bat --help
Traceback (most recent call last):
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\Scripts\mamba-script.py", line 6, in <module>
from mamba.mamba import main
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\lib\site-packages\mamba\mamba.py", line 50, in <module>
from mamba import repoquery as repoquery_api
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\lib\site-packages\mamba\repoquery.py", line 12, in <module>
def _repoquery(query_type, q, pool, fmt=api.QueryFormat.JSON):
AttributeError: module 'libmambapy' has no attribute 'QueryFormat'
psh ❯ mamba.exe --help
Traceback (most recent call last):
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\Scripts\mamba-script.py", line 6, in <module>
from mamba.mamba import main
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\lib\site-packages\mamba\mamba.py", line 50, in <module>
from mamba import repoquery as repoquery_api
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\lib\site-packages\mamba\repoquery.py", line 12, in <module>
def _repoquery(query_type, q, pool, fmt=api.QueryFormat.JSON):
AttributeError: module 'libmambapy' has no attribute 'QueryFormat'
psh ❯ mamba --help
Traceback (most recent call last):
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\Scripts\mamba-script.py", line 6, in <module>
from mamba.mamba import main
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\lib\site-packages\mamba\mamba.py", line 50, in <module>
from mamba import repoquery as repoquery_api
File "C:\Users\mtrevisa\AppData\Local\Continuum\envy\lib\site-packages\mamba\repoquery.py", line 12, in <module>
def _repoquery(query_type, q, pool, fmt=api.QueryFormat.JSON):
AttributeError: module 'libmambapy' has no attribute 'QueryFormat'
I discussed with @marcelotrevisani and he installed mamba in an environment different from the base env -- that is often problematic.
I wonder if @jonashaag @zertrin @sherdim that is also the case for you?
In my case I tried to install mamba in the base environnement.
In the end I think I worked around it by reinstalling a fresh micromamba, but that was unfortunate that installing it in the existing base env of miniconda failed.
I had the same problem and miniconda reinstallation solved it. Not quite innovative and profound solution but it worked. Seems like some broken dependencies in existing base environment.
I've found what was causing the issue for me. Maybe someone will make use of it.
So I was installing mamba from conda-forge channel using command: conda install -n base -c conda-forge mamba
, but on the other hand, I had a script for updating conda environment using mamba update --all
, but it was using the default channel and after that, mamba became corrupted with AttributeError: module 'libmambapy' has no attribute 'QueryFormat'
.
Changing update command to mamba update -c conda-forge -all
fixed the issue.
I had similar issues as well, but I managed to work around them.
I had mamba installed in the base env, as recommended. When running mamba from the base env all was fine, but as soon as I activated another env it didn't work.
The tell was that mamba.bat
was working as intended, it was the plain mamba
that didn't work.
This was using git bash on Windows 10, which doesn't seem to resolve names properly...
The fix was to just alias mamba
to mamba.bat
in my bash profile.