use pipenv -h and other commands like --venv -install, UnicodeDecodeError: 'utf-8', pipenv commands are error.And i can't find answers in other places.
F:\proc_py\pipEnv>pipenv -h
Traceback (most recent call last):
File "e:\python3.6\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "e:\python3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "E:\python3.6\Scripts\pipenv.exe\__main__.py", line 5, in <module>
File "e:\python3.6\lib\site-packages\pipenv\__init__.py", line 47, in <module>
from .cli import cli
File "e:\python3.6\lib\site-packages\pipenv\cli\__init__.py", line 3, in <modu
le>
from .command import cli
File "e:\python3.6\lib\site-packages\pipenv\cli\command.py", line 7, in <modul
e>
import crayons
File "e:\python3.6\lib\site-packages\pipenv\patched\crayons.py", line 49, in <
module>
is_powershell = "powershell" in shellingham.detect_shell()[0]
File "e:\python3.6\lib\site-packages\pipenv\vendor\shellingham\__init__.py", l
ine 22, in detect_shell
shell = get_shell(pid, max_depth=max_depth)
File "e:\python3.6\lib\site-packages\pipenv\vendor\shellingham\nt.py", line 10
0, in get_shell
processes = dict(_iter_process())
File "e:\python3.6\lib\site-packages\pipenv\vendor\shellingham\nt.py", line 78
, in _iter_process
info = {'executable': str(pe.szExeFile.decode('utf-8'))}
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid
start byte
I do not know why, pipenv commands are error.And i can't find answers in other places.
I've met same problem and was lurking internet for a solution but having not much time and figured out some possible workaround for making it
I was tryin to install PIPEnvironment through Pycharm interpreter settings and problem occured:
Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\pipenv\vendor\click\decorators.py", line 17, in new_func
[pipenv.exceptions.VirtualenvCreationException]: return f(get_current_context(), *args, **kwargs)
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\pipenv\cli\command.py", line 208, in cli
[pipenv.exceptions.VirtualenvCreationException]: clear=state.clear,
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 506, in ensure_virtualenv
[pipenv.exceptions.VirtualenvCreationException]: python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\pipenv\core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]: extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]: Traceback (most recent call last):
File "C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\virtualenv.py", line 939, in call_subprocess
line = line.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 280: invalid continuation byte
I went to a file
"C:\Users\ogmamedo\AppData\Roaming\Python\Python37\site-packages\virtualenv.py"
And changed code like this:
encoding = sys.getdefaultencoding()
fs_encoding = 'OEM' #sys.getfilesystemencoding()
This helped me to pass that stage (first 10 seconds) when bug was occuring.
Why it's 'OEM'?
Because as we see in that file - there are a call to a system prompt (cmd shell), and my system's cmd shell has encoding 'OEM'.
I'll point that this is a workaround, not a proper solution, but due to a lack of time and interest figuring out which of sides this bug belongs to (pycharm or pipenv) I wont continue to a proper solution.
Related
I wanted to generate requirements.txt of only used packages in a given project. pip freeze works fine but saves all packages in the environment including those that you don't use in your current project, and once you have a bunch of installed packages, it become tedious deleting manually the packages that aren't required for the current project.
I tried pipreqs which is supposed to generate requirements.txt based on used packages in the current project, by running the below approaches in terminal but they throw the same error:
$ python -m pipreqs.pipreqs .
$ pipreqs
$ pipreqs /project/location
Error:
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\Scripts\pipreqs.exe\__main__.py", line 7, in <module>
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\lib\site-packages\pipreqs\pipreqs.py", line 488, in main
init(args)
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\lib\site-packages\pipreqs\pipreqs.py", line 415, in init
candidates = get_all_imports(input_path,
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\lib\site-packages\pipreqs\pipreqs.py", line 115, in get_all_imports
contents = f.read()
File "C:\Program Files\Python39\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 1237: character maps to <undefined>
Could anyone help spot the error?
At the point where the crash is happening, pipreqs is thinking that your input is cp1252 but the data contains a character that is not supported within that character set/encoding (eg, byte 0x8d).
You could try passing --encoding argument and experiment with different values (like utf-8 or utf-16)
Even though #rasjani spotted a significant point of the cause of the error, when I implemented the rule, a new error popped up again and took me quite some couple of minutes to reflex. Here was what happened.
$ pipreqs --encoding=utf8 C:\Users\myProjects\dataScience\sp_app\advance_app
New Error:
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\Scripts\pipreqs.exe\__main__.py", line 7, in <module>
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\lib\site-packages\pipreqs\pipreqs.py", line 488, in main
init(args)
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\lib\site-packages\pipreqs\pipreqs.py", line 478, in init
generate_requirements_file(path, imports, symbol)
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\lib\site-packages\pipreqs\pipreqs.py", line 157, in generate_requirements_file
with _open(path, "w") as out_file:
File "C:\Program Files\Python39\lib\contextlib.py", line 117, in __enter__
return next(self.gen)
File "C:\Users\myProjects\dataScience\sp_app\advance_app\venv\lib\site-packages\pipreqs\pipreqs.py", line 81,
in _open
file = open(filename, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'C:UsersmyProjectsdataSciencesp_appadvance_appsrcpackagesadvance_app\\requirements.txt'
Note: The reason why this happen is because I used single \ for the path instead of \\.
Solution:
$ pipreqs --encoding=utf8 C:\\Users\\myProjects\\dataScience\\sp_app\\advance_app
Output:
INFO: Successfully saved requirements file in C:\Users\myProjects\dataScience\sp_app\advance_app\requirements.txt
I am trying to install simpletransformers via pip, but it gives me the following error:
"ERROR: Exception:
Traceback (most recent call last):
File "/sw/arch/Debian10/EB_production/2021/software/Python/3.9.5-GCCcore-10.3.0/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 180, in _main
status = self.run(options, args)
File "/sw/arch/Debian10/EB_production/2021/software/Python/3.9.5-GCCcore-10.3.0/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 204, in wrapper
return func(self, options, args)
File "/sw/arch/Debian10/EB_production/2021/software/Python/3.9.5-GCCcore-10.3.0/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 393, in run
installed = install_given_reqs(
File "/sw/arch/Debian10/EB_production/2021/software/Python/3.9.5-GCCcore-10.3.0/lib/python3.9/site-packages/pip/_internal/req/__init__.py", line 77, in install_given_reqs
requirement.install(
File "/sw/arch/Debian10/EB_production/2021/software/Python/3.9.5-GCCcore-10.3.0/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 782, in install
install_wheel(
File "/sw/arch/Debian10/EB_production/2021/software/Python/3.9.5-GCCcore-10.3.0/lib/python3.9/site-packages/pip/_internal/operations/install/wheel.py", line 810, in install_wheel
_install_wheel(
File "/sw/arch/Debian10/EB_production/2021/software/Python/3.9.5-GCCcore-10.3.0/lib/python3.9/site-packages/pip/_internal/operations/install/wheel.py", line 653, in _install_wheel
file.save()
File "/sw/arch/Debian10/EB_production/2021/software/Python/3.9.5-GCCcore-10.3.0/lib/python3.9/site-packages/pip/_internal/operations/install/wheel.py", line 419, in save
with open(self.dest_path, "wb") as dest:
UnicodeEncodeError: 'latin-1' codec can't encode character '\U0001f4f9' in position 75: ordinal not in range(256)
"
I am working on jupyterhub and have tried creating a conda environment with Python version 3.7 as suggested in other cases, but the problem was not solved.
Any tips are welcome!
The problem comes from the encodage.
I think these topics could help you.
Streamlit install fails on GitLab CI with UnicodeEncodeError
'ascii' codec can't encode character : ordinal not in range (128)
In general google your error message you'll find o lot of related post and maybe your answer.
I'm trying to install brownie but I get multiple errors when the installation ends.
pipx install eth-brownie
Traceback (most recent call last):
File "C:\Users\Dhruv\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Dhruv\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Dhruv\AppData\Roaming\Python\Python310\Scripts\pipx.exe\__main__.py", line 7, in <module>
File "C:\Users\Dhruv\AppData\Roaming\Python\Python310\site-packages\pipx\main.py", line 779, in cli
return run_pipx_command(parsed_pipx_args)
File "C:\Users\Dhruv\AppData\Roaming\Python\Python310\site-packages\pipx\main.py", line 202, in run_pipx_command
return commands.install(
File "C:\Users\Dhruv\AppData\Roaming\Python\Python310\site-packages\pipx\commands\install.py", line 60, in install
venv.install_package(
File "C:\Users\Dhruv\AppData\Roaming\Python\Python310\site-packages\pipx\venv.py", line 238, in install_package
subprocess_post_check_handle_pip_error(pip_process)
File "C:\Users\Dhruv\AppData\Roaming\Python\Python310\site-packages\pipx\util.py", line 349, in subprocess_post_check_handle_pip_error
print(completed_process.stderr, file=pip_error_fh, end="")
File "C:\Users\Dhruv\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2502' in position 559: character maps to <undefined>
I've installed pipx successfully using these commands and even added its path to the env variables
python -m pip install --user pipx
python -m pipx ensurepath
I'm using python veriosn 3.10.2
This my first time in Odoo, I use MacOS. Python 3.7 and Odoo12. I followed the steps, after installing pip3 install -r requirements.txt i use ./odoo-bin
but I failed. it shows
Traceback (most recent call last):
File "./odoo-bin", line 8, in <module>
odoo.cli.main()
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/cli/command.py", line 60, in main
o.run(args)
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/cli/server.py", line 176, in run
main(args)
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/cli/server.py", line 124, in main
odoo.tools.config.parse_config(args)
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/tools/config.py", line 337, in parse_config
odoo.netsvc.init_logger()
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/netsvc.py", line 133, in init_logger
resetlocale()
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/tools/translate.py", line 1201, in resetlocale
for ln in get_locales():
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/tools/translate.py", line 1170, in get_locales
lang = locale.getdefaultlocale()[0]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 568, in getdefaultlocale
return _parse_localename(localename)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 495, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
Try exporting the below to your ~/.bash_profile.
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Everytime I run docker-compose up on my machine (macOS 10.13.5, latest docker version) I get this error
Traceback (most recent call last): File "docker-compose", line 6, in
File "compose/cli/main.py", line 71, in main File
"compose/cli/main.py", line 124, in perform_command File
"compose/cli/command.py", line 41, in project_from_options File
"compose/cli/command.py", line 126, in get_project File
"compose/project.py", line 96, in from_config File
"compose/network.py", line 320, in get_networks File
"compose/network.py", line 125, in true_name File
"compose/network.py", line 146, in _set_legacy_flag File
"compose/network.py", line 106, in inspect File
"site-packages/docker/utils/decorators.py", line 19, in wrapped File
"site-packages/docker/api/network.py", line 211, in inspect_network
File "site-packages/docker/utils/decorators.py", line 46, in inner
File "site-packages/docker/api/client.py", line 194, in _get File
"site-packages/requests/sessions.py", line 521, in get File
"site-packages/requests/sessions.py", line 494, in request File
"site-packages/requests/sessions.py", line 424, in prepare_request
File "site-packages/requests/utils.py", line 195, in get_netrc_auth
File "netrc.py", line 33, in init File "netrc.py", line 42, in
_parse File "shlex.py", line 105, in get_token File "shlex.py", line 136, in read_token File
"/Users/distiller/compose-osx-release/compose/venv/lib/python3.6/codecs.py",
line 321, in decode UnicodeDecodeError: 'utf-8' codec can't decode
byte 0x80 in position 33: invalid start byte
Ok so apparently there is a problem with the current version of docker-compose for macOS... It's just my guess, but anyhow here is how I solved it
curl -L https://github.com/docker/compose/releases/download/1.14.0-rc2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Then restarted the terminal
I ran into this same issue and this may also be related to your .env files.
Ensure that your .env files are UTF-8.
sudo apt install moreutils
isutf8 yourfile.env
If isutf8 returns no output it's likely a valid UTF-8 file.
Additionally, check the contents of the .env file you're referencing in your docker-compose.yml. Any incorrectly decrypted secrets/values you may be using locally can cause this problem too.
If in doubt, clear the env file and readd lines until you hit the error.
I have 2 ideas:
1. try to reinstall your python
2. use not the latest docker version, but the latest stable
What worked for me was creating an empty .env file in the directory I run docker-compose in (encoded as UTF-8).
you need to go to the pycharm env file, double click it and install the python env file. Then run the code [docker-compose up airflow-init] again, it'll work.