Forums

Error in collectstatic command: <No such file or directory>

Hi, when i use collectstatic command as bellow this error happend,when no such file and directory( Contract_Assistant/static) exist in my project. my correct file path is as this:/home/SocialAI/Contract_Assistant/static/ExpertSystem/resources/postagger.model, and basically why django search for that file in that path? by the way my code and this command work fine with no error before.

thanks in advance for any help

~/Contract_Assistant $ python3.8 manage.py collectstatic

error: cannot open input model file: /home/SocialAI/Contract_Assistant/Contract_Assistant/static/ExpertSystem/resources/postagger.model <No such file or directory>

Django is searches for static files in the directories that you specify in your STATICFILES_DIRS setting. From the path that it cannot find, I'd guess that you have /home/SocialAI/Contract_Assistant/Contract_Assistant/static in that setting. Are you really sure that the directory /home/SocialAI/Contract_Assistant/Contract_Assistant/static exists? You can easily check with:

ls /home/SocialAI/Contract_Assistant/Contract_Assistant/static

My static files is in /home/SocialAI/Contract_Assistant/static and django already found it and collected all static files, but I don't know why django search for that wrong address I explained above.

I check static directory as you say and as i expect, the result was:

ls: cannot access '/home/SocialAI/Contract_Assistant/Contract_Assistant/static': No such file or directory

as seen below my project directories is :

07:48 ~/Contract_Assistant $ dir

Contract_Assistant ExpertSystem RuleManager ServiceUser pycache db.sqlite3 decorators.py favicon.ico locale manage.py media runtimelog.txt static venv zarinpal

and when i check this command, django can find my file:

07:51 ~/Contract_Assistant $ dir static/ExpertSystem/resources

chunker.model langModel.mco postagger.model

for testing i delete all files in resources directory but django still search for that file and show same error msg!

this is my setting file: setting .py

so, what's wrong?

First thing: The file that you are saying exists is at /home/SocialAI/Contract_Assistant/static/ExpertSystem/resources/postagger.model but the error is talking about a file at /home/SocialAI/Contract_Assistant/Contract_Assistant/static/ExpertSystem/resources/postagger.model

The strangeness of the error message ("error: cannot open input model file") makes me think that the problem may not be in your static files configuration, but in your code. If you are trying to open a file in your code at import time, then that could prevent collectstatic from importing your apps so it can collect your static files. Check your code for something that might be trying to load that file at import time.

Thank you glenn,

If you are trying to open a file in your code at import time

that was the key note, i tried to load postagger.model file in various places but file path was incorrect. so by modifing path all errors gone and collectstatic work as expected. Thank you again :-)

Thanks for letting us know!