Thursday 3 October, 2024

requirements.txt garbled or looks corrupt? Here is the fix

 When running pip freeze > requirements.txt from PowerShell (which is the default terminal on IDEs like PyCharm),  you might see the output properly in Windows but may not work properly on Linux. This is because the file is encoded as UTF-16LE and not as UTF-8. To do it properly, the following command works:

 pip freeze | Out-File -Encoding utf8 requirements.txt