Python: importing lmfit.models fails

2019-08-21 11:18发布

问题:

This post is related to my other one where I was told to use lmfit to fix my problem.

I installed lmfit in anaconda Prompt with conda install --channel "conda-forge" lmfit which worked. But now when I try to use it in my Programm I get the following error:

ModuleNotFoundError: No module named 'lmfit.model'; 'lmfit' is not a package

Thats how the beginning of my Program looks like:

import numpy as np
import math
import scipy    #I dont need scipy, but I read, that lmfit needs scipy. It doesn't change anything when its there or not.
import matplotlib.pyplot as plt
from lmfit.model import GaussianModel

I also tried to import lmfit seperatly like:

import lmfit
from lmfit.model import GaussianModel

But it doesn't work either...

I tried everything from the lmfit website, but using the "git"-thing in Anaconda Prompt gives me an error (something like command doesn't exist)

I also found this post, and importing from lmfit import * works. Now I have the problem that I somehow need to import the GaussianModel, which I don't know how to do. If I just add from lmfit import GaussianModel I get the Error

ImportError: cannot import name 'GaussianModel'

I also read something about the order of importing packages and modules is important - is this what the problem is about? How can I fix this?

I work on windows with anaconda/spider.