Conda skeleton pypi: ModuleNotFoundError: No module named 'numpy'

自闭症网瘾萝莉.ら 提交于 2021-02-17 02:31:26

问题


I'm trying to create a conda package from a package I've uploaded to PyPI, by following this tutorial. I've downloaded and installed the latest Anaconda environment for Linux (Ubuntu 16.04).

After installing conda-build I am able to run the conda skeleton pypi click command as per the example, but running it for my own package mf2, I encounter the error:

ModuleNotFoundError: No module named 'numpy'

resulting in

Error: command failed: <anaconda_path>/python setup.py install

I've already tried to follow the advice from https://github.com/conda/conda/issues/824 but that hasn't helped me:

$ conda install -n _build numpy

EnvironmentLocationNotFound: Not a conda environment: /scratch/anaconda3/envs/_build

$ conda install -n base numpy
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

How do I get get this to work? Is the problem that numpy is somehow not installed in the temporary environment it's creating? If so, how do I make sure it does work?

Full output:

$ conda --version
conda 4.8.1

$ which python
/scratch/anaconda3/bin/python
$ python --version
Python 3.7.4

$ conda skeleton pypi mf2
Warning, the following versions were found for mf2
2019.11.2
2019.11.3
Using 2019.11.3
Use --version to specify a different version.
Using url https://files.pythonhosted.org/packages/cc/15/a2fe948e5fdbf9ca3c5e0c18631a1ec7268ff4dcb62b10e0f0b329cbfdce/mf2-2019.11.3.tar.gz (13 KB) for mf2.
Downloading mf2
PyPI URL:  https://files.pythonhosted.org/packages/cc/15/a2fe948e5fdbf9ca3c5e0c18631a1ec7268ff4dcb62b10e0f0b329cbfdce/mf2-2019.11.3.tar.gz
Unpacking mf2...
done
working in /tmp/tmp9da0e5rkconda_skeleton_mf2-2019.11.3.tar.gz
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /scratch/anaconda3/conda-bld/skeleton_1578498754522/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place


The following NEW packages will be INSTALLED:

    _libgcc_mutex:    0.1-main               
    ca-certificates:  2019.11.27-0           
    certifi:          2019.11.28-py37_0      
    ld_impl_linux-64: 2.33.1-h53a641e_7      
    libedit:          3.1.20181209-hc058e9b_0
    libffi:           3.2.1-hd88cf55_4       
    libgcc-ng:        9.1.0-hdf63c60_0       
    libstdcxx-ng:     9.1.0-hdf63c60_0       
    ncurses:          6.1-he6710b0_1         
    openssl:          1.1.1d-h7b6447c_3      
    pip:              19.3.1-py37_0          
    python:           3.7.6-h0371630_1       
    pyyaml:           5.2-py37h7b6447c_0     
    readline:         7.0-h7b6447c_5         
    setuptools:       44.0.0-py37_0          
    sqlite:           3.30.1-h7b6447c_0      
    tk:               8.6.8-hbc83047_0       
    wheel:            0.33.6-py37_0          
    xz:               5.2.4-h14c3975_4       
    yaml:             0.1.7-had09818_2       
    zlib:             1.2.11-h7b6447c_3      

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Applying patch: '/tmp/tmp9da0e5rkconda_skeleton_mf2-2019.11.3.tar.gz/pypi-distutils.patch'
Trying to apply patch as-is
INFO:conda_build.source:Trying to apply patch as-is
INFO conda_build.source:apply_patch(596): Trying to apply patch as-is
patching file core.py
Hunk #1 succeeded at 167 with fuzz 2 (offset 1 line).
Traceback (most recent call last):
  File "setup.py", line 2, in <module>
    import mf2
  File "/tmp/tmp9da0e5rkconda_skeleton_mf2-2019.11.3.tar.gz/mf2-2019.11.3/mf2/__init__.py", line 9, in <module>
    from .multiFidelityFunction import MultiFidelityFunction
  File "/tmp/tmp9da0e5rkconda_skeleton_mf2-2019.11.3.tar.gz/mf2-2019.11.3/mf2/multiFidelityFunction.py", line 12, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'
$PYTHONPATH = /tmp/tmp9da0e5rkconda_skeleton_mf2-2019.11.3.tar.gz/mf2-2019.11.3

Leaving build/test directories:
  Work:
 /scratch/anaconda3/conda-bld/skeleton_1578498754522/work 
  Test:
 /scratch/anaconda3/conda-bld/skeleton_1578498754522/test_tmp 
Leaving build/test environments:
  Test:
source activate  /scratch/anaconda3/conda-bld/skeleton_1578498754522/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_ 
  Build:
source activate  /scratch/anaconda3/conda-bld/skeleton_1578498754522/_build_env 


Error: command failed: /scratch/anaconda3/conda-bld/skeleton_1578498754522/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/bin/python setup.py install

回答1:


I suspect that the advice in that GitHub issue is rather outdated. The current version of conda skeleton pypi doesn't really care about the active environment nor does it use _build, but instead creates a temporary environment in which to attempt to install the package and eventually output a recipe. One can add additional requirements to the temporary environment using the --extra-specs flag. In your case, this should be something like

conda skeleton pypi --extra-specs numpy mf2


来源:https://stackoverflow.com/questions/59649808/conda-skeleton-pypi-modulenotfounderror-no-module-named-numpy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!