Python site packages utf 8

Не даёт нормально установить любой пакет python через pip из-за utf-8. Что делать?

Собственно всё в тайтле, добавлю что у меня название пользователя русское, сменил но папка в users всё равно остаётся прежней — через админстратора не даёт изменить, пишет что где то кто то ей пользуется в данный момент.
Команду использую pip install pyTelegramBotAPI

ramBotAPI . error
Exception:
Traceback (most recent call last):
File «c:\users\бог\appdata\local\programs\python\python36-32\lib\site-packages\pip\compat\__init__.py», line 73, in console_to_str
return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe1 in position 50: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «c:\users\бог\appdata\local\programs\python\python36-32\lib\site-packages\pip\basecommand.py», line 215, in main
status = self.run(options, args)
File «c:\users\бог\appdata\local\programs\python\python36-32\lib\site-packages\pip\commands\install.py», line 342, in run
prefix=options.prefix_path,
File «c:\users\бог\appdata\local\programs\python\python36-32\lib\site-packages\pip\req\req_set.py», line 784, in install
**kwargs
File «c:\users\бог\appdata\local\programs\python\python36-32\lib\site-packages\pip\req\req_install.py», line 878, in install
spinner=spinner,
File «c:\users\бог\appdata\local\programs\python\python36-32\lib\site-packages\pip\utils\__init__.py», line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File «c:\users\бог\appdata\local\programs\python\python36-32\lib\site-packages\pip\compat\__init__.py», line 75, in console_to_str
return s.decode(‘utf_8’)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe1 in position 50: invalid continuation byte

sim3x

Не используйте кириллицу в винде

Попробуйте устанавить в директорию, которая не имеет в пути кириллицу

Я уже сам понял что кириллицу лучше не использовать..

А как поменять директорию то?

sim3x

cehka, Изменить имя профиля можно (если вы уже переименовали своего пользователя по английски): винда хранит настройки пути к профилю пользователя в реестре: HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfilesList в этой ветке есть разделы названные по SIDам пользователей. Найдете раздел для своего пользователя (по параметру ProfileImagePath внутри раздела) и удалите его (или переименуйте или сохраните в файл, а потом удалите). После этого перезагрузитесь. Когда винда не увидит настройки профиля, она будет считать что это новый пользователь и создаст новый профиль. Название профиля будет содержать уже новое имя пользователя. Вам останется только скопировать содержимое старого профиля в новый, заодно избавитесь от накопленного в профиле хлама.

Тупо переименовать каталог не получится, т.к. вы сами сидите в нем. Кроме того виндовый Медиа центр любит держать файлы все время открытыми даже если вы не пользуетесь им в данный момент (на сколько я понимаю открывает их служба раздающая медиа контент по сети, если активирована домашняя группа или даже если не активирована).

PS: Вообще винда нормально работает с русскими каталогами уже давно. А вот разнообразные приложения могут плохо понимать не английские имена файлов/каталогов до сих пор. Но это не проблема винды. Просто разрабам хорошо бы быть более внимательными в этом отношении. Часто этим страдает американский софт.
Кстати в тексте ошибки каталог с русским именем отображается нормально, это значит, что и питон вполне справляется с этой проблемой. Скорее всего проблема именно в кривом модуле.

Источник

site — Site-specific configuration hook¶

This module is automatically imported during initialization. The automatic import can be suppressed using the interpreter’s -S option.

Importing this module will append site-specific paths to the module search path and add a few builtins, unless -S was used. In that case, this module can be safely imported with no automatic modifications to the module search path or additions to the builtins. To explicitly trigger the usual site-specific additions, call the site.main() function.

Changed in version 3.3: Importing the module used to trigger paths manipulation even when using -S .

It starts by constructing up to four directories from a head and a tail part. For the head part, it uses sys.prefix and sys.exec_prefix ; empty heads are skipped. For the tail part, it uses the empty string and then lib/site-packages (on Windows) or lib/python X.Y /site-packages (on Unix and macOS). For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to sys.path and also inspects the newly added path for configuration files.

Changed in version 3.5: Support for the “site-python” directory has been removed.

If a file named “pyvenv.cfg” exists one directory above sys.executable, sys.prefix and sys.exec_prefix are set to that directory and it is also checked for site-packages (sys.base_prefix and sys.base_exec_prefix will always be the “real” prefixes of the Python installation). If “pyvenv.cfg” (a bootstrap configuration file) contains the key “include-system-site-packages” set to anything other than “true” (case-insensitive), the system-level prefixes will not be searched for site-packages; otherwise they will.

A path configuration file is a file whose name has the form name .pth and exists in one of the four directories mentioned above; its contents are additional items (one per line) to be added to sys.path . Non-existing items are never added to sys.path , and no check is made that the item refers to a directory rather than a file. No item is added to sys.path more than once. Blank lines and lines beginning with # are skipped. Lines starting with import (followed by space or tab) are executed.

An executable line in a .pth file is run at every Python startup, regardless of whether a particular module is actually going to be used. Its impact should thus be kept to a minimum. The primary intended purpose of executable lines is to make the corresponding module(s) importable (load 3rd-party import hooks, adjust PATH etc). Any other initialization is supposed to be done upon a module’s actual import, if and when it happens. Limiting a code chunk to a single line is a deliberate measure to discourage putting anything more complex here.

For example, suppose sys.prefix and sys.exec_prefix are set to /usr/local . The Python X.Y library is then installed in /usr/local/lib/python X.Y . Suppose this has a subdirectory /usr/local/lib/python X.Y /site-packages with three subsubdirectories, foo , bar and spam , and two path configuration files, foo.pth and bar.pth . Assume foo.pth contains the following:

# foo package configuration foo bar bletch
# bar package configuration bar

Источник

Как решить проблему с кодировкой UTF-8?

Пишу в PyCharm и вроде как там с кодировкой проблем не должно возникать, однако удача меня обошла стороной.
При запуске локального сервера возникает следующая ошибка:

Unhandled exception in thread started by .wrapper at 0x035B1B28>
Traceback (most recent call last):
File «C:\Users\Tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py», line 227, in wrapper
fn(*args, **kwargs)
File «C:\Users\Tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py», line 149, in inner_run
ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
File «C:\Users\Tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py», line 164, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File «C:\Users\Tony\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py», line 74, in __init__
super(WSGIServer, self).__init__(*args, **kwargs)
File «C:\Users\Tony\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py», line 453, in __init__
self.server_bind()
File «C:\Users\Tony\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\simple_server.py», line 50, in server_bind
HTTPServer.server_bind(self)
File «C:\Users\Tony\AppData\Local\Programs\Python\Python36-32\lib\http\server.py», line 138, in server_bind
self.server_name = socket.getfqdn(host)
File «C:\Users\Tony\AppData\Local\Programs\Python\Python36-32\lib\socket.py», line 673, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xcf in position 5: invalid continuation byte

Заморочился и пересохранил все файлы в UTF-8 — не помогло. Пересмотрел кодировку каждого файла в самом PyCharm’e — везде UTF-8. Нашел на некоторых форумах такую же проблему — в качестве решения предлагалось переименовать имя компьютера в ASCII кодировку (на латинице короче говоря). Весь путь на латинице — ноль изменений. В каждом файле писал комментарий с кодировкой:
# coding: utf8
и вот так, что одно и то же
# -*- coding: utf-8 -*- .
Результата как не было, так и нет. Весь день копаюсь, так до сих пор и без понятия в чем дело.
Использую фреймворк Django (может что на нем завязано).
Надеюсь на вашу помощь. Заранее спасибо!

Оценить 1 комментарий

Источник

Читайте также:  404 Error - Page Not Found
Оцените статью