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.
from lmfit.models import GaussianModel
. – Morceaulmfit
directory orlmfit.py
file, since in that case, Python will attempt to import that (which is likely not the installed package). – Morceaupip install lmfit
orconda install -c gsecars lmfit
should work. After seeing one of those work, verify that you can doimport lmfit
from the python or ipython prompt in spyder or from a python session started in the "anaconda prompt". You do NOT need to be in the folder wherelmfit
got unpacked. In fact, you don't want a folder or file namedlmfit
in your working directory -- that will cause the confusion Evert is talking about. – Loryloseimport lmfit
, thenprint(lmfit.__file__
) will tell you what file (with its full path) it is using. See if that looks like the correct file, or an incorrect file. – Morceauconda install -c gsecars lmfit
made it work :) The path of my file is the following (for others which have the same problem): C:\Users\Carina\Anaconda3\lib\site-packages\lmfit-0.9.8-py3.6.egg\lmfit__init_.py_ – Solidago