Conda-build: LoadLibrary error when invoking conda-build on Windows 7

Created on 17 Oct 2018  Â·  15Comments  Â·  Source: conda/conda-build

conda build

Actual Behavior

$ conda build
Traceback (most recent call last):
  File "C:\Anaconda3\Scripts\conda-build-script.py", line 6, in <module>
    from conda_build.cli.main_build import main
  File "C:\Anaconda3\lib\site-packages\conda_build\cli\main_build.py", line 18, in <module>
    import conda_build.api as api
  File "C:\Anaconda3\lib\site-packages\conda_build\api.py", line 22, in <module>
    from conda_build.config import Config, get_or_merge_config, DEFAULT_PREFIX_LENGTH as _prefix_length
  File "C:\Anaconda3\lib\site-packages\conda_build\config.py", line 17, in <module>
    from .variants import get_default_variant
  File "C:\Anaconda3\lib\site-packages\conda_build\variants.py", line 15, in <module>
    from conda_build.utils import ensure_list, trim_empty_keys, get_logger
  File "C:\Anaconda3\lib\site-packages\conda_build\utils.py", line 10, in <module>
    import libarchive
  File "C:\Anaconda3\lib\site-packages\libarchive\__init__.py", line 1, in <module>
    from .entry import ArchiveEntry
  File "C:\Anaconda3\lib\site-packages\libarchive\entry.py", line 6, in <module>
    from . import ffi
  File "C:\Anaconda3\lib\site-packages\libarchive\ffi.py", line 27, in <module>
    libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
  File "C:\Anaconda3\lib\ctypes\__init__.py", line 434, in LoadLibrary
    return self._dlltype(name)
  File "C:\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None

Expected Behavior

usage: conda-build [-h] [-V] [-n] [--output] [--python PYTHON] [--perl PERL]
                   [--numpy NUMPY] [--R R_BASE] [--lua LUA]
                   [--bootstrap BOOTSTRAP]
                   [--append-file APPEND_SECTIONS_FILE]
                   [--clobber-file CLOBBER_SECTIONS_FILE]
                   [-m VARIANT_CONFIG_FILES] [--old-build-string] [--check]
                   [--no-anaconda-upload] [--no-include-recipe] [-s] [-t]
                   [--no-test] [-b] [-p] [--skip-existing] [--keep-old-work]
                   [--dirty] [-q] [--debug] [--token TOKEN] [--user USER]
                   [--no-force-upload] [--password PASSWORD] [--sign SIGN]
                   [--sign-with SIGN_WITH] [--identity IDENTITY]
                   [--config-file CONFIG_FILE] [--repository REPOSITORY]
                   [--no-activate] [--no-build-id] [--croot CROOT] [--verify]
                   [--output-folder OUTPUT_FOLDER]
                   [--no-prefix-length-fallback] [--prefix-length-fallback]
                   [--prefix-length _PREFIX_LENGTH] [--no-locking]
                   [--no-remove-work-dir] [--long-test-prefix]
                   [--no-long-test-prefix] [--keep-going]
                   [--cache-dir CACHE_DIR] [--no-copy-test-source-files]
                   [-c CHANNEL] [--override-channels]
                   RECIPE_PATH [RECIPE_PATH ...]
conda-build: error: the following arguments are required: RECIPE_PATH

Steps to Reproduce

Honestly no idea

Output of conda info
     active environment : None
       user config file : C:\Users\<redacted>\.condarc
 populated config files : C:\Users\<redacted>\.condarc
          conda version : 4.5.11
    conda-build version : 3.16.1
         python version : 3.7.0.final.0
       base environment : C:\Anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/win-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Anaconda3\pkgs
                          C:\Users\<redacted>\AppData\Local\conda\conda\pkgs
       envs directories : C:\Anaconda3\envs
                          C:\Users\<redacted>\AppData\Local\conda\conda\envs
                          C:\Users\<redacted>\.conda\envs
               platform : win-64
             user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Windows/7 Windows/6.1.7601
          administrator : True
             netrc file : None
           offline mode : False

Most helpful comment

Like @tritemio and @justinGilmer, we just hit this with Python 3.7 under AppVeyor. Unlike @tritemio, @justinGilmer, and presumably everyone else on this thread, we never run conda build.

Instead, simply attempting to run conda info --all early in our CI pipeline fails with a similar traceback:

conda info --all
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
    Traceback (most recent call last):
      File "C:\Miniconda37-x64\lib\site-packages\conda\exceptions.py", line 1043, in __call__
        return func(*args, **kwargs)
      File "C:\Miniconda37-x64\lib\site-packages\conda\cli\main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "C:\Miniconda37-x64\lib\site-packages\conda\cli\conda_argparse.py", line 80, in do_call
        module = import_module(relative_mod, __name__.rsplit('.', 1)[0])
      File "C:\Miniconda37-x64\lib\importlib\__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "C:\Miniconda37-x64\lib\site-packages\conda\cli\main_info.py", line 19, in <module>
        from ..core.index import _supplement_index_with_system
      File "C:\Miniconda37-x64\lib\site-packages\conda\core\index.py", line 9, in <module>
        from .package_cache_data import PackageCacheData
      File "C:\Miniconda37-x64\lib\site-packages\conda\core\package_cache_data.py", line 15, in <module>
        from conda_package_handling.api import InvalidArchiveError
      File "C:\Miniconda37-x64\lib\site-packages\conda_package_handling\api.py", line 3, in <module>
        from libarchive.exception import ArchiveError as _LibarchiveArchiveError
      File "C:\Miniconda37-x64\lib\site-packages\libarchive\__init__.py", line 1, in <module>
        from .entry import ArchiveEntry
      File "C:\Miniconda37-x64\lib\site-packages\libarchive\entry.py", line 6, in <module>
        from . import ffi
      File "C:\Miniconda37-x64\lib\site-packages\libarchive\ffi.py", line 27, in <module>
        libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
      File "C:\Miniconda37-x64\lib\ctypes\__init__.py", line 434, in LoadLibrary
        return self._dlltype(name)
      File "C:\Miniconda37-x64\lib\ctypes\__init__.py", line 356, in __init__
        self._handle = _dlopen(self._name, mode)
    TypeError: LoadLibrary() argument 1 must be str, not None
`$ C:\Miniconda37-x64\Scripts\conda-script.py info --all`

An unexpected error has occurred. Conda has prepared the above report.

Clearly, our previously working AppVeyor configuration should not need to explicitly activate a base environment before running the idempotent conda info subcommand – but that's just what we now need to do.

Clearly, there be effluvious dragons here. :dragon:

How would anyone not have the Anaconda Prompt? We install it in both Miniconda and Anaconda.

Please use Google. Search for conda activate.

@mingwandroid: Sadly, the conda activate subcommand failed hard under AppVeyor the last time we tested it. Although the decrepit activate script still behaves as expected, end users shouldn't have to explicitly activate base environments merely to run trivial subcommands like conda info.

If conda now requires base environments to be activated as a hard prerequisite to running any subcommand, then conda itself should automate this requirement on behalf of end users. Although the fix would ultimately be trivial on our end (e.g., via a one-liner running activate before conda info), we refuse on general principle to do so. This constitutes a significant breaking change and should be resolved as such by upstream Anaconda repositories.

Somebody disastrously broke backward compatibility, guys. </shaking_my_head>

All 15 comments

This is unlikely anything to do with conda-build; probably some badly written software has installed some non-system DLLs in your C:\Windows\System32 folder. Please open an issue at https://github.com/anaconda-issues/issues

Thanks.

The issue only started after I foolishly did conda install -n base conda-build conda-env. Is it possible that I caused some binary incompatibility? I tried to find command output to see if I could roll back to the previous version but I had closed that terminal window before I realized what happened.

I have the same issue on Windows 10.

BTW the correct issue tracker is https://github.com/ContinuumIO/anaconda-issues

It seems to be an issue with the PATH on windows. If you add %USERPROFILE%\AppData\Local\Continuum\anaconda3\bin to your PATH variable it works or you need to execute the build command inside the Anaconda Prompt.

Yes, our software does not work if you do not activate your environment(s), which the Anaconda Prompt does. Alternatively you can add to PATH but that doesn't run package activation scripts so some things will not work correctly.

@mingwandroid I've been using Anaconda and Conda build for over a year and haven't needed to use the Anaconda Prompt. Did something change in the recent version of conda-build?

Also is there some documentation on what exactly Anaconda Prompt does and how it's different from adding to PATH? And what happens to Miniconda users who dosn't have the prompt?

For debugging purposes yes, it looks like conda build works correctly in the Anaconda Prompt. It also works if I run activate base in a regular shell (CMD or Powershell). Seems like whatever worked before was a fluke, and that conda build should be run with the base environment active.

I got this error when testing a build inside Pycharm. I never thought about if Pycharm does proper activation of conda environments (although conda environments can be added easily as interpreters in the settings). This does not seem the case. I will try to find a solution.

Downgrading to 3.15 fixes the problem

conda install -n base conda==3.15 --yes
conda build
#usage: conda-build [-h] [-V] [-n] [--output] [--python PYTHON] [--perl PERL]
#                   [--numpy NUMPY] [--R R_BASE] [--lua LUA]
#                   [--bootstrap BOOTSTRAP]
#                   [--append-file APPEND_SECTIONS_FILE]
#                   [--clobber-file CLOBBER_SECTIONS_FILE]
#                   [-m VARIANT_CONFIG_FILES] [-e EXCLUSIVE_CONFIG_FILES]
#                   [--old-build-string] [--check] [--no-anaconda-upload]
#                   [--no-include-recipe] [-s] [-t] [--no-test] [-b] [-p]
#                   [--skip-existing] [--keep-old-work] [--dirty] [-q]
#                   [--debug] [--token TOKEN] [--user USER] [--label LABELS]
#                   [--no-force-upload] [--password PASSWORD] [--sign SIGN]
#                   [--sign-with SIGN_WITH] [--identity IDENTITY]
#                   [--config-file CONFIG_FILE] [--repository REPOSITORY]
#                   [--no-activate] [--no-build-id] [--croot CROOT] [--verify]
#                   [--no-verify] [--strict-verify]
#                   [--output-folder OUTPUT_FOLDER]
#                   [--no-prefix-length-fallback] [--prefix-length-fallback]
#                   [--prefix-length _PREFIX_LENGTH] [--no-locking]
#                   [--no-remove-work-dir] [--error-overlinking]
#                   [--no-error-overlinking] [--long-test-prefix]
#                   [--no-long-test-prefix] [--keep-going]
#                   [--cache-dir CACHE_DIR] [--no-copy-test-source-files]
#                   [--merge-build-host] [--stats-file STATS_FILE]
#                   [--extra-deps EXTRA_DEPS [EXTRA_DEPS ...]] [-c CHANNEL]
#                   [--override-channels]
#                   RECIPE_PATH [RECIPE_PATH ...]
#conda-build: error: the following arguments are required: RECIPE_PATH

conda install -n base conda-build==3.16.1 --yes
conda build
#Traceback (most recent call last):
#  File "C:\Anaconda3\Scripts\conda-build-script.py", line 6, in <module>
#    from conda_build.cli.main_build import main
#  File "C:\Anaconda3\lib\site-packages\conda_build\cli\main_build.py", line 18, in <module>
#    import conda_build.api as api
#  File "C:\Anaconda3\lib\site-packages\conda_build\api.py", line 22, in <module>
#    from conda_build.config import Config, get_or_merge_config, DEFAULT_PREFIX_LENGTH as _prefix_length
#  File "C:\Anaconda3\lib\site-packages\conda_build\config.py", line 17, in <module>
#    from .variants import get_default_variant
#  File "C:\Anaconda3\lib\site-packages\conda_build\variants.py", line 15, in <module>
#    from conda_build.utils import ensure_list, trim_empty_keys, get_logger
#  File "C:\Anaconda3\lib\site-packages\conda_build\utils.py", line 10, in <module>
#    import libarchive
#  File "C:\Anaconda3\lib\site-packages\libarchive\__init__.py", line 1, in <module>
#    from .entry import ArchiveEntry
#  File "C:\Anaconda3\lib\site-packages\libarchive\entry.py", line 6, in <module>
#    from . import ffi
#  File "C:\Anaconda3\lib\site-packages\libarchive\ffi.py", line 27, in <module>
#    libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
#  File "C:\Anaconda3\lib\ctypes\__init__.py", line 434, in LoadLibrary
#    return self._dlltype(name)
#  File "C:\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
#    self._handle = _dlopen(self._name, mode)
#TypeError: LoadLibrary() argument 1 must be str, not None

Also is there some documentation on what exactly Anaconda Prompt does and how it's different from adding to PATH? And what happens to Miniconda users who dosn't have the prompt?

How would anyone not have the Anaconda Prompt? We install it in both Miniconda and Anaconda.

Please use Google. Search for conda activate.

I'm seeing this exact error in AppVeyor with the latest conda-build (but I don't see it if I downgrade to conda-build 4.3.34):

https://ci.appveyor.com/project/astrofrog/pywwt/builds/21017691

Any idea what this could be due to?

I am seeing this on AppVeyor too, but only on python 3.7, works on python 3.6

https://ci.appveyor.com/project/tritemio/phconvert/builds/23832227/job/mtw68shi02g0rh2j

Like @tritemio and @justinGilmer, we just hit this with Python 3.7 under AppVeyor. Unlike @tritemio, @justinGilmer, and presumably everyone else on this thread, we never run conda build.

Instead, simply attempting to run conda info --all early in our CI pipeline fails with a similar traceback:

conda info --all
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
    Traceback (most recent call last):
      File "C:\Miniconda37-x64\lib\site-packages\conda\exceptions.py", line 1043, in __call__
        return func(*args, **kwargs)
      File "C:\Miniconda37-x64\lib\site-packages\conda\cli\main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "C:\Miniconda37-x64\lib\site-packages\conda\cli\conda_argparse.py", line 80, in do_call
        module = import_module(relative_mod, __name__.rsplit('.', 1)[0])
      File "C:\Miniconda37-x64\lib\importlib\__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "C:\Miniconda37-x64\lib\site-packages\conda\cli\main_info.py", line 19, in <module>
        from ..core.index import _supplement_index_with_system
      File "C:\Miniconda37-x64\lib\site-packages\conda\core\index.py", line 9, in <module>
        from .package_cache_data import PackageCacheData
      File "C:\Miniconda37-x64\lib\site-packages\conda\core\package_cache_data.py", line 15, in <module>
        from conda_package_handling.api import InvalidArchiveError
      File "C:\Miniconda37-x64\lib\site-packages\conda_package_handling\api.py", line 3, in <module>
        from libarchive.exception import ArchiveError as _LibarchiveArchiveError
      File "C:\Miniconda37-x64\lib\site-packages\libarchive\__init__.py", line 1, in <module>
        from .entry import ArchiveEntry
      File "C:\Miniconda37-x64\lib\site-packages\libarchive\entry.py", line 6, in <module>
        from . import ffi
      File "C:\Miniconda37-x64\lib\site-packages\libarchive\ffi.py", line 27, in <module>
        libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
      File "C:\Miniconda37-x64\lib\ctypes\__init__.py", line 434, in LoadLibrary
        return self._dlltype(name)
      File "C:\Miniconda37-x64\lib\ctypes\__init__.py", line 356, in __init__
        self._handle = _dlopen(self._name, mode)
    TypeError: LoadLibrary() argument 1 must be str, not None
`$ C:\Miniconda37-x64\Scripts\conda-script.py info --all`

An unexpected error has occurred. Conda has prepared the above report.

Clearly, our previously working AppVeyor configuration should not need to explicitly activate a base environment before running the idempotent conda info subcommand – but that's just what we now need to do.

Clearly, there be effluvious dragons here. :dragon:

How would anyone not have the Anaconda Prompt? We install it in both Miniconda and Anaconda.

Please use Google. Search for conda activate.

@mingwandroid: Sadly, the conda activate subcommand failed hard under AppVeyor the last time we tested it. Although the decrepit activate script still behaves as expected, end users shouldn't have to explicitly activate base environments merely to run trivial subcommands like conda info.

If conda now requires base environments to be activated as a hard prerequisite to running any subcommand, then conda itself should automate this requirement on behalf of end users. Although the fix would ultimately be trivial on our end (e.g., via a one-liner running activate before conda info), we refuse on general principle to do so. This constitutes a significant breaking change and should be resolved as such by upstream Anaconda repositories.

Somebody disastrously broke backward compatibility, guys. </shaking_my_head>

Was this page helpful?
0 / 5 - 0 ratings