Brownie Installation Issue - python

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

Related

I stumbled upon "UnicodeDecodeError:" after running "python -m pipreqs.pipreqs . " on VSC terminal

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

"codec can't encode character" error when I run "pipx install eth-brownie"

Not sure if this helps but I couldn't run "python3 -m pip install --user pipx" and "python3 -m pipx ensurepath". Instead of "python3" I just used "python" and also ran "python -m pipx ensurepath --force"
It told me pipx is ready to go and then I ran "pipx install eth-brownie" and got the below.
C:\Users\gmlad>pipx install eth-brownie
Traceback (most recent call last):
File "E:\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "E:\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\users\gmlad\appdata\roaming\python\python310\scripts\pipx.exe\__main__.py", line 7, in <module>
File "C:\Users\gmlad\AppData\Roaming\Python\Python310\site-packages\pipx\main.py", line 779, in cli
return run_pipx_command(parsed_pipx_args)
File "C:\Users\gmlad\AppData\Roaming\Python\Python310\site-packages\pipx\main.py", line 202, in run_pipx_command
return commands.install(
File "C:\Users\gmlad\AppData\Roaming\Python\Python310\site-packages\pipx\commands\install.py", line 60, in install
venv.install_package(
File "C:\Users\gmlad\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\gmlad\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 "E:\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>
You can try to install brownie by clone from github repository like blow. Then after that you can delete all the code if you want. And you already can use the brownie cli on your computer.
git clone https://github.com/eth-brownie/brownie.git
cd brownie
python3 setup.py install
Try upgrading pip using:
python -m pip install --upgrade pip
If that doesn't work, then you might need to set your locale to UTF-8. There is a closed GitHub issue on the pipx repo regarding this issue: https://github.com/pypa/pipx/issues/73.

Command '['git' 'clone', '--recurse-submodules', '--', 'ssh://git#git/b2b/py_client.git'] returned non-zero exit status 128

I am trying to create virtualenv with make setup and poetry in Git Bash:
$ make setup
poetry install --no-root
Creating virtualenv ad-ml in C:\Users\user1\Documents\ad_ml\.venv
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.
CalledProcessError
Command '['C:\\Users\\user1\\AppData\\Local\\Programs\\Git\\mingw64\\bin\\git.exe'
, 'clone', '--recurse-submodules', '--', 'ssh://git#git.bcb.local:7999/b2b/py_client.git',
'C:\\Users\\EMANZH~1\\AppData\\Local\\Temp\\pypoetry-git-py_clien9fdvh9lr']'
returned non-zero exit status 128.
at ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\utils\_compat.py:217 in run
and get CalledProcessError with exit status 128 and another exception:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user1\Anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\user1\Anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\user1\AppData\Roaming\Python\Scripts\poetry.exe\__main__.py", line 7, in <module>
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\__init__.py", line 5, in main
return Application().run()
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\console_application.py", line 142, in run
trace.render(io, simple=isinstance(e, CliKitException))
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\ui\components\exception_trace.py", line 232, in render
return self._render_exception(io, self._exception)
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\ui\components\exception_trace.py", line 269, in _render_exception
self._render_snippet(io, current_frame)
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\ui\components\exception_trace.py", line 289, in _render_snippet
self._render_line(io, code_line)
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\ui\components\exception_trace.py", line 402, in _render_line
io.write_line("{}{}".format(indent * " ", line))
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\io\io_mixin.py", line 65, in write_line
super(IOMixin, self).write_line(string, flags)
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\api\io\io.py", line 66, in write_line
self._output.write_line(string, flags=flags)
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\api\io\output.py", line 69, in write_line
self.write(string, flags=flags, new_line=True)
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\api\io\output.py", line 61, in write
self._stream.write(to_str(formatted))
File "C:\Users\user1\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\io\output_stream\stream_output_stream.py", line 24, in write
self._stream.write(string)
File "C:\Users\user1\Anaconda3\lib\encodings\cp1251.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 27: character maps to <undefined>
Are there any ideas how to fix this error, any help would be much appreciated.
pc windows 10, git bash 2.34.0, cloned repo with sourcetree from bitbucket, python 3.8.8
Check first if this is similar to python-poetry/poetry issue 3297, which refers to a pypa/virtualenv issue 1986
The first link includes (by Daniel Taylor):
We downgrade virtualenv inside the conda environment in our circle CI windows executors, not sure if it with pip or not.
So adding a step like this to your yml config should fix the issue (or just adding virtualenv=20.0.33 to the step where you install your conda dependencies):
- run: conda install virtualenv=20.0.33
The OP Taky proposes in the comments:
I changed dependency link to py_client.git in pyproject.toml from "ssh" to "https", and that's worked for me.

Python build package error- 'virtualenv' has no attribute 'cli_run'

Using Azure Databricks to build a python package. Received the following error from command:
python3 -m build
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/databricks/python3/lib/python3.7/site-packages/build/__main__.py", line 214, in <module>
main(sys.argv[1:], 'python -m build')
File "/databricks/python3/lib/python3.7/site-packages/build/__main__.py", line 206, in main
build_package(args.srcdir, outdir, distributions, config_settings, not args.no_isolation, args.skip_dependencies)
File "/databricks/python3/lib/python3.7/site-packages/build/__main__.py", line 94, in build_package
_build_in_isolated_env(builder, outdir, distributions, config_settings)
File "/databricks/python3/lib/python3.7/site-packages/build/__main__.py", line 52, in _build_in_isolated_env
with IsolatedEnvBuilder() as env:
File "/databricks/python3/lib/python3.7/site-packages/build/env.py", line 65, in __enter__
executable, scripts_dir = _create_isolated_env_virtualenv(self._path)
File "/databricks/python3/lib/python3.7/site-packages/build/env.py", line 156, in _create_isolated_env_virtualenv
result = virtualenv.cli_run(cmd, setup_logging=False)
AttributeError: module 'virtualenv' has no attribute 'cli_run'
I was able to solve the same issue (although in an AWS environment) by upgrading pip and virtualenv:
python3 -m pip install --upgrade pip virtualenv

use pipenv -h, UnicodeDecodeError: 'utf-8'

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.

Categories

Resources