Python Beeware Briefcase Git SHA issue - python

I'm trying to teach myself to use the beeware briefcase package for Python, although having issues setting it up. I've got pyenv installed, and my local python version in the root of my project is set to 3.8.9. I'm using windows and Powershell
In PowerShell, I've created the python virtual environment, and have installed briefcase via pip.
I've installed git as well, and linked the repo to github.
When I try to run "briefcase new", and go through the prompts, I receive the following traceback (for both powershell and gitbash):
(I've removed my root details in below errors)
Traceback (most recent call last):
File "C:\~\.pyenv\pyenv-win\versions\3.8.9\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\~\.pyenv\pyenv-win\versions\3.8.9\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\~\CodeProjects\beeware-tutorial\.venv\Scripts\briefcase.exe\__main__.py", line 7, in <module>
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\briefcase\__main__.py", line 14, in main
command(**options)
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\briefcase\commands\new.py", line 537, in __call__
return self.new_app(template=template, **options)
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\briefcase\commands\new.py", line 488, in new_app
cached_template = self.update_cookiecutter_cache(
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\briefcase\commands\base.py", line 569, in update_cookiecutter_cache
f"Using existing template (sha {head.commit.hexsha}, "
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\git\refs\symbolic.py", line 217, in _get_commit
obj = self._get_object()
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\git\refs\symbolic.py", line 210, in _get_object
return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\git\objects\base.py", line 85, in new_from_sha
oinfo = repo.odb.info(sha1)
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\git\db.py", line 43, in info
hexsha, typename, size = self._git.get_object_header(bin_to_hex(binsha))
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\git\cmd.py", line 1253, in get_object_header
return self.__get_object_header(cmd, ref)
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\git\cmd.py", line 1240, in __get_object_header
return self._parse_object_header(cmd.stdout.readline())
File "c:\~\codeprojects\beeware-tutorial\.venv\lib\site-packages\git\cmd.py", line 1198, in _parse_object_header
raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip()))
ValueError: SHA could not be resolved, git returned: b''

Not sure how I managed to fix the issue but I uninstalled git version 2.37.1 and installed git version 2.30.2, used GitBash to create a new environment, and installed a briefcase.
Seems to have solved the issue.

Related

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.

exception in newsplease commoncrawl.py file

i am using newsplease library that i have cloned from https://github.com/fhamborg/news-please.
i want to use newsplease to get news artices from commoncrawl news datasets.
i am running commoncrawl.py file as instruct here.
i have used the command below -
python -m newsplease.examples.commoncrawl
on executing the following command i am getting following errors -
my_local_download_dir_warc=./cc_download_warc/
my_local_download_dir_article=./cc_download_articles/
delete_warc_after_extraction=False
my_number_of_extraction_processes=1
INFO:newsplease.crawler.commoncrawl_crawler:executing: aws s3 ls --recursive s3://commoncrawl/crawl-data/CC-NEWS/ --no-sign-request > .tmpaws.txt && awk '{ print $4 }' .tmpaws.txt && rm .tmpaws.txt
INFO:newsplease.crawler.commoncrawl_crawler:found 2 files at commoncrawl.org
INFO:newsplease.crawler.commoncrawl_crawler:creating extraction process pool with 1 processes
INFO:newsplease.crawler.commoncrawl_extractor:found local file ./cc_download_warc/https%3A%2F%2Fcommoncrawl.s3.amazonaws.com%2F, not downloading again due to configuration
Traceback (most recent call last):
File "/home/prateek/.local/lib/python3.6/site-packages/warcio/recordloader.py", line 236, in _detect_type_load_headers
rec_headers = self.arc_parser.parse(stream, statusline)
File "/home/prateek/.local/lib/python3.6/site-packages/warcio/recordloader.py", line 312, in parse
raise StatusAndHeadersParserException(msg, parts)
warcio.statusandheaders.StatusAndHeadersParserException: Wrong # of headers, expected arc headers ['uri', 'ip-address', 'archive-date', 'content-type', 'length'], Found ['<?xml', 'version="1.0"', 'encoding="UTF-8"?>']
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/prateek/.local/lib/python3.6/site-packages/newsplease/examples/commoncrawl.py", line 172, in <module>
main()
File "/home/prateek/.local/lib/python3.6/site-packages/newsplease/examples/commoncrawl.py", line 168, in main
continue_process=True)
File "/home/prateek/.local/lib/python3.6/site-packages/newsplease/crawler/commoncrawl_crawler.py", line 320, in crawl_from_commoncrawl
log_pathname_fully_extracted_warcs=__log_pathname_fully_extracted_warcs)
File "/home/prateek/.local/lib/python3.6/site-packages/newsplease/crawler/commoncrawl_crawler.py", line 230, in __start_commoncrawl_extractor
log_pathname_fully_extracted_warcs=__log_pathname_fully_extracted_warcs)
File "/home/prateek/.local/lib/python3.6/site-packages/newsplease/crawler/commoncrawl_extractor.py", line 338, in extract_from_commoncrawl
self.__run()
File "/home/prateek/.local/lib/python3.6/site-packages/newsplease/crawler/commoncrawl_extractor.py", line 292, in __run
self.__process_warc_gz_file(local_path_name)
File "/home/prateek/.local/lib/python3.6/site-packages/newsplease/crawler/commoncrawl_extractor.py", line 231, in __process_warc_gz_file
for record in ArchiveIterator(stream):
File "/home/prateek/.local/lib/python3.6/site-packages/warcio/archiveiterator.py", line 110, in _iterate_records
self.record = self._next_record(self.next_line)
File "/home/prateek/.local/lib/python3.6/site-packages/warcio/archiveiterator.py", line 262, in _next_record
self.check_digests)
File "/home/prateek/.local/lib/python3.6/site-packages/warcio/recordloader.py", line 88, in parse_record_stream
known_format))
File "/home/prateek/.local/lib/python3.6/site-packages/warcio/recordloader.py", line 243, in _detect_type_load_headers
raise ArchiveLoadFailed(msg + str(se.statusline))
warcio.exceptions.ArchiveLoadFailed: Unknown archive format, first line: ['<?xml', 'version="1.0"', 'encoding="UTF-8"?>']
what is the error here how can i resolve this.
https://github.com/fhamborg/news-please says that adopt the config section in
newsplease/examples/commoncrawl.py.
what does this mean ?
i have copied the configurations from this file and pasted in
config.cfg which is present in the newsplease/config directory.
is this what thay have instructed ? or i have made a mistake here.
i am using python 3.6. i have only one python installed in my machine.
this error is because of the libraries being used by the newsplease. mistake is made when we manually install every library, while installing focus on the versions of packages. version info of every library is given in setup.py file. install exact version given in setup.py file.
now there may be problems while executing the setup.py.
so use this command -
python3 setup.py install
if you need to uninstall all the previous verions of installed packeges then run -
pip3 freeze --user | xargs pip3 uninstall -y
for more ways to do this click here

Is it possible to run jupyter from nside a virtual env

For now I was only using python 2.7 (installed for all users, added to path, windows 10 machine) but I want to switch to 3.8, to be able to use both of them I first installed virtualenv in my system python 2.7.
Then installed python 3.8.1 for all user without adding it to path.
Created my virtualenv like that : virtualenv c:\virtualEnvs\p38x64_jupytertest -p C:\Python38-32\python.exe
then activated it : C:\virtualEnvs\p38x64_jupytertest\Scripts\activate.bat
checked if python 3.8.1 was selected with : python --version (it was)
then installed jupyter inside my virtualenv : pip install jupyter
Then when I ran jupyter notebook I got
Traceback (most recent call last):
File "C:\Python38-32\Lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python38-32\Lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\virtualEnvs\p38x64_jupytertest3\Scripts\jupyter-notebook.EXE\__main__.py", line 7, in <module>
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\jupyter_core\application.py", line 268, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
app.initialize(argv)
File "<c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\decorator.py:decorator-gen-7>", line 2, in initialize
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\notebook\notebookapp.py", line 1720, in initialize
self.init_webapp()
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\notebook\notebookapp.py", line 1482, in init_webapp
self.http_server.listen(port, self.ip)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\tcpserver.py", line 152, in listen
self.add_sockets(sockets)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
self._handlers[sock.fileno()] = add_accept_handler(
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
io_loop.add_handler(sock, accept_handler, IOLoop.READ)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
File "C:\Python38-32\Lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
After some googling I find a lot of tutorial that explain how to install jupyter in you system python then add virtualenvs to it, but not how to install it INSIDE a virtual env.
The reason I did that is because I want my python 3 project to be isolated since I have a lot of python 2.7 projects (up until now I was not using virtualenv and every package is installed in my system python 2.)
Any idea of why I have this exception?
Thanks.
PS : yes it says p38x64_jupytertest3 in the stacktrace because the venv is not p38x64_jupytertest but p38x64_jupytertest3 in fact
know issue : https://github.com/jupyter/notebook/issues/4613
Reverting to python 3.7 for the moment

Kernel Error problem in Jupyter Notebook on PyCharm 2018 IDE

I am struggling with running Jupyter Notebook on PyCharm2018 Community Edition in Windows 10. I created a Virtual Environment with python version 3.6.6 and other necessary packages. I installed jupyter notebook (ipython-7.8.0v, jupyter-1.0.0v) as well following its documentation. As, I am using a specific python version for this application, I want to create a separate ipython kernel (version 5.1.2) for python 3 in a specific path and then add it to jupyter kernelspecs as follows:
ipython kernel install --prefix /tmp
jupyter kernelspec install /tmp/share/jupyter/kernels/python3
When I run an example ipython notebook after following these instructions, the notebook is returning Kernel Error problem stating Could not find a kernel matching Python 2 . I am unable to understand, why its resulting in this. There is no trace of python2 being used anywhere during my installation. I even created python3 kernels separately using above instructions and changed my notebook to kernel to that, but still the same Kernel Error. Virtual Environment I created for this application also uses python3.6 exec file from my Anaconda Installation.
I have looked around similar questions on this problem, but none of them could help me solve this so far. The back trace of this error is as follows.
Traceback (most recent call last):
File "D:\Anaconda3\envs\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\Anaconda3\envs\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\***\pycharm_workspace\trail\venv\lib\site-packages\ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "D:\***\pycharm_workspace\trail\venv\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
app.initialize(argv)
File "<D:\***\pycharm_workspace\trail\venv\lib\site-packages\decorator.py:decorator-gen-125>", line 2, in initialize
File "D:\***\pycharm_workspace\trail\venv\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "D:\***\pycharm_workspace\trail\venv\lib\site-packages\ipykernel\kernelapp.py", line 472, in initialize
self.write_connection_file()
File "D:\***\pycharm_workspace\trail\venv\lib\site-packages\ipykernel\kernelapp.py", line 199, in write_connection_file
iopub_port=self.iopub_port, control_port=self.control_port)
File "D:\***\pycharm_workspace\trail\venv\lib\site-packages\jupyter_client\connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "D:\Anaconda3\envs\python36\lib\contextlib.py", line 81, in __enter__
return next(self.gen)
File "D:\**\pycharm_workspace\trail\venv\lib\site-packages\jupyter_core\paths.py", line 404, in secure_write
win32_restrict_file_to_user(fname)
File "D:\**\pycharm_workspace\trail\venv\lib\site-packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
import win32api
**ImportError: DLL load failed: The specified procedure could not be found.**
Thanks in advance for the help.

Flask cli can't import application set with FLASK_APP

Following the Flask 0.11 documentation, I cloned the Flask repo, created a virtualenv, and installed Flask via pip install flask. I went into the examples/flaskr directory, set the FLASK_APP environment variable, then executed:
flask run
However, I got the following error:
Traceback (most recent call last):
File "c:\python34\Lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "c:\python34\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\GitHub\flask\venv\Scripts\flask.exe\__main__.py", line 9, in <module>
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 478, in main
cli.main(args=args, prog_name=name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 345, in main
return AppGroup.main(self, *args, **kwargs)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 696, in main
rv = self.invoke(ctx)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 1055, in invoke
cmd_name, cmd, args = self.resolve_command(ctx, args)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 1094, in resolve_command
cmd = self.get_command(ctx, cmd_name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 316, in get_command
rv = info.load_app().cli.get_command(ctx, name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 209, in load_app
rv = locate_app(self.app_import_path)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 89, in locate_app
__import__(module)
ImportError: No module named 'flaskr'
How do I correctly run the flaskr example?
I was setting FLASK_APP=flaskr. Since I hadn't installed my app as a package in my virtualenv, I needed to add the .py extension.
export FLASK_APP=flaskr.py
Flask issue for the eclipse and PyDev extension, you can set a path like this.
Flask 1.0.2 and Python 3.6 already installed on Windows 10.
flask.cli.NoAppException
flask.cli.NoAppException: module 'src' has no attribute 'Hello'
Run Flask in proper folder path to resolve this issue.

Categories

Resources