1
votes

I am having the following error while executing the following command in django:

django-admin makemessages -l en

the error is this string: Please specify the source encoding through --from-code or through a comment as specified in http://www.python.org/peps/pep-0263.html.

the settings.py configurations is this:

LANGUAGE_CODE = 'ru'

LANGUAGES = [
('en', 'English'),
('ru', 'Russian'),
]  

USE_I18N = True 

LOCALE_PATHS = [
os.path.join(BASE_DIR, 'locale')
]

My django version is 2.1 and I am using pyCharm on Ubuntu 18.04. I did some research I found out that there is bug but it was corrected after some time.

1

1 Answers

1
votes

checkout if your project virtual environment folder, is in the root directory of your project like:

project
  |
  |----project
  |----app1
  |----app2
  ...
  |----project_env
  |----manage.py

if so, use this command:

django-admin makemessages -l en -i project_env

the problem is when you run makemessages command it will look in all of sub directories for messages, so the libraries in site-packages cause this error. by using -i you can ignore environment folder.

as a recommendation!

actually that would be better to not include environment folder in project root folder, instead you can add a requirements.txt file and add all project dependencies to it. so next time after activating a new virtual environment you can easily reinstall project dependencies with this command:

pip install -r requirements.txt

this python virtual environment document would be helpful.