Peek problem, unable to import 'django.db'. pylint(import-error)


While trying to execute the makemigrations in the CMD I experience an error: unable to import ‘django.db’. pylint(import-error).

Probably I have select the wrong Interpreter path. Currently I have selected my python interpreter path:

I have installed a venv for my Django projects, but when I select this venv as interpreter path, I got the next error:
Module ‘django.db.models’ has no ‘Charfield’ member; maybe ‘CharField’?pylint(no-member)

What should be my interpreter path to execute the makemagrations function?

Actually, for that second error, you want to check your code, specifically your file.

I’m guessing that somewhere in your model, you typed Charfield instead of CharField.
(It’s an easy mistake to make.)

Yes that’s correct, totally overlooked, my fault. Thanks for refer me too this typo.

May I ask you Ken what you would advice to use as interpreter path? When I use the python path (~\AppData\Local\Programs\Python\Python38-32) it looks like it works fine as well.

Currently I have specified the interpreter path to:

I have multiple virtual environments created for my projects. I always point my interpreter to whichever virtual environment I’m currently using for a particular project. If you’ve created a venv for your project, then that’s what you would want to use. (I almost never use the system Python installation for development work, but that’s me - your mileage may vary.)

So yes, I generally recommend using your venv - but, I also acknowledge that different people may have different requirements and work habits, so it’s a relatively weak recommendation. (I might go so far as to say that if you don’t know for sure what you want to use, then you do want to use the venv.)


1 Like