Conda environment with pip -e : ModuleNotFoundError: No module named 'setuptools'

Viewed 955

I have a conda file with some standard dependencies and then I want to install a customer package using pip -e. My environment.yml looks like this:

name: my_env
channels:
  - conda-forge
  - defaults

dependencies:
  - python==3.7.0 
  - pip==19.3.1
  - pip:
    - -e ./path_to_my_package

When I try to create the environment by running conda env create -f conda.yml the creation of the environment fails with an error: ModuleNotFoundError: No module named 'setuptools' . This is surprising, I have setuptools installed in the conda package and my Ubuntu.

The command conda tries to run and that throws an error is:

/home/path/to/my/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/path/to/my/package/setup.py'"'"'; __file__='"'"'/pat/to/my/package/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps

When I run this command outside of the conda create command, it works well.

My setup.py looks simple, it is just:

import setuptools

if __name__ == "__main__":
    setuptools.setup()

I am stunned. Can anybody help?

EDIT

I am on Windows Subsystem for Linux (version 1)

1 Answers

Does your package has the approriate section in, e.g., pyproject.toml file like this

[metadata]
name = "mypackage"
version = "0.0.1"

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

See also setuptools (Note the quotation marks in [metadata])

Related