ModuleNotFoundError: No module named 'fontawesomefree'

Viewed 1065

I am getting this error when I try to import fonrawesomefree icons to my django project. I used official django docs

requirements.txt file have following

# some other requirements
fontawesomefree==5.15.4

settings.py have following:

INSTALLED_APPS = [
    # some other installed apps
    'fontawesomefree',
]

base.html file have following

<head>
     #some other link & script files
     <link href="{% static 'fontawesomefree/css/all.min.css' %}" rel="stylesheet" 
     type="text/css">
</head>

Project structure

[projectname]/
├── [projectname]/
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
|
|── [App1]
|── [static]/ 
|   ├── [css]
|   ├── [Javascript]
|   └── [Images]
|
|── [templates]
|── manage.py
└── requirements.txt

When I try to run server I get following error:

ModuleNotFoundError: No module named 'fontawesomefree'

Any help is appreciated

1 Answers

Adding a package to the requirements.txt is not enough. The requirements.txt file is just a list of packages that you want to install.

You need a package manager, like pip3, or the package manager of your virtual environment to download the package, and run the installation script.

You can install the fontawesomefree and other packages listed for example with pip3 by running the following command in the shell:

pip3 install -r requirements.txt

or look up how to install packages with your package manager.

Related