'Cannot install lmfit, "Command returned non-zero exit status 1"

I'm trying to install the lmfit package but I keep getting the same error:

Command '['C:\\Users\\me\\AppData\\Local\\Programs\\Spyder\\Python\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\me\\AppData\\Local\\Temp\\tmpeds77q3s', '--quiet', 'setuptools_scm']' returned non-zero exit status 1.

I'm working with Spyder, Python version 3.7. I looked online but I can't seem to find a solution that works for me.

EDIT: So, i opened a command line on Miniconda3, run pip install setuptools_smc and then pip install lmfit this happened:

(base) C:\Users\me>pip install lmfit

Collecting lmfit

Using cached lmfit-1.0.3-py3-none-any.whl

Requirement already satisfied: scipy>=1.4 in c:\programdata\miniconda3\lib\site-packages (from lmfit) (1.7.3)

Requirement already satisfied: asteval>=0.9.22 in c:\programdata\miniconda3\lib\site-packages (from lmfit) (0.9.26)

Requirement already satisfied: uncertainties>=3.0.1 in c:\programdata\miniconda3\lib\site-packages (from lmfit) (3.1.6)

Requirement already satisfied: numpy>=1.18 in c:\programdata\miniconda3\lib\site-packages (from lmfit) (1.22.1)

Requirement already satisfied: future in c:\programdata\miniconda3\lib\site-packages (from uncertainties>=3.0.1->lmfit) (0.18.2)

Installing collected packages: lmfit

Successfully installed lmfit-1.0.3

after that, I went back to Spyder and simply tried to run import lmfit on a new, clean script. That's what I got:

runfile('C:/Users/me/Desktop/untitled0.py', wdir='C:/Users/me/Desktop')

Traceback (most recent call last):

File "C:\Users\me\Desktop\untitled0.py", line 8, in import lmfit

ModuleNotFoundError: No module named 'lmfit'

feels like I'm back at the starting point. i forgot to mention that; but I'm running on Windows.

P.s.: i don't think I'm using any virtual environment, just Miniconda3 and Spyder



Solution 1:[1]

installing lmfit with pip works fine at least on macOS, but admittedly I have never tried on Windows... To me it seems that it cannot find setuptools_scm even though we do declare it as a dependency.

Try installing that package first (pip install setuptools_scm) and then install lmfit (pip install lmfit) again. I don't see how that would make a difference, but it's worth a try! Also, please do provide the exact command you use to install lmfit.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1