Try to generate binary file with music21 library - pyinstaller

music21 version
6.7.1
Problem summary
I try to generate a binary file with pyinstaller. And I get that error:
[17939] WARNING: file already exists but should not: /tmp/_MEIxs8i9Y/pyarrow/lib.cpython-36m-x86_64-linux-gnu.so
Traceback (most recent call last):
File "main.py", line 1, in <module>
from NeckDisplayer import NeckDisplayer
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "NeckDisplayer.py", line 2, in <module>
import music21.pitch
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "music21/__init__.py", line 192, in <module>
AttributeError: module 'music21' has no attribute 'alpha'
[17942] Failed to execute script 'main' due to unhandled exception!
Steps to reproduce
Do a simple program and generate a binary file with pyinstaller:
pyinstaller --onefile main.py
More information
I try to do this on Ubuntu 18.04 with python 3.6.

This was fixed in music21 v7.3.3.

Related

importlib.metadata.PackageNotFoundError: regex while building an .exe with pyinstaller

I am trying to build an executable with pyinstaller and I am getting the following errors:
Traceback (most recent call last):
File "transformers/utils/versions.py", line 105, in require_version
File "importlib/metadata.py", line 551, in version
File "importlib/metadata.py", line 524, in distribution
File "importlib/metadata.py", line 187, in from_name
importlib.metadata.PackageNotFoundError: regex
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "chatbot2.py", line 8, in <module>
File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
File "transformers/__init__.py", line 43, in <module>
File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
File "transformers/dependency_versions_check.py", line 41, in <module>
File "transformers/utils/versions.py", line 120, in require_version_core
File "transformers/utils/versions.py", line 107, in require_version
importlib.metadata.PackageNotFoundError: The 'regex!=2019.12.17' distribution was not found and is required by this application.
Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git master
[30391] Failed to execute script 'chatbot2' due to unhandled exception!
I am using PyInstaller version 5.0.dev0 and Python version 3.9.1.
I tried pip3.9 install transformers, pip3.9 install regex, I tried adding hooks hook-regex.py and hook-transformers.py.
I would really appreciate any suggestions! Thank you!

Cannot init the db for Airflow

I have some experience starting starting up Apache Airflow but I have now an error when I try to airflow db init command. The error is as below. I am running Airflow on virtual env with Python 3.8. Any help would appreciated. I am not sure to understand this error as I managed to init the db without importing any _cffi_backend module in the past.
The error:
airflow) airflow#26c8ed88c008:~/airflow$ airflow db init
Traceback (most recent call last):
File "/home/airflow/.local/bin/airflow", line 8, in <module>
sys.exit(main())
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/__main__.py", line 40, in main
args.func(args)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/cli_parser.py", line 47, in command
func = import_string(import_path)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/module_loading.py", line 32, in import_string
module = import_module(module_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/commands/db_command.py", line 24, in <module>
from airflow.utils import cli as cli_utils, db
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/db.py", line 26, in <module>
from airflow.jobs.base_job import BaseJob # noqa: F401
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/__init__.py", line 19, in <module>
import airflow.jobs.backfill_job
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/backfill_job.py", line 29, in <module>
from airflow import models
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/__init__.py", line 20, in <module>
from airflow.models.baseoperator import BaseOperator, BaseOperatorLink
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py", line 59, in <module>
from airflow.models.taskinstance import Context, TaskInstance, clear_task_instances
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 57, in <module>
from airflow.models.variable import Variable
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/variable.py", line 24, in <module>
from cryptography.fernet import InvalidToken as InvalidFernetToken
File "/usr/lib/python3/dist-packages/cryptography/fernet.py", line 17, in <module>
from cryptography.hazmat.primitives import hashes, padding
File "/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/padding.py", line 13, in <module>
from cryptography.hazmat.bindings._padding import lib
ModuleNotFoundError: No module named '_cffi_backend'
Airflow 2 has hard requirement on cryptography module being installed and operating. So you have to install it properly. There are some distributions of Linux that you need to add some additional packages to make it works.
You can take a look at this query and similar problems and possibly you will find out how cryptography can be installed or reinstalled cleanly.
No module named _cffi_backend
Check the installation docs for cryptography: https://cryptography.io/en/latest/installation/
If you are using Alpine, make sure you install the following:
$ sudo apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
Similarly for Debian/buster:
$ sudo apt-get install build-essential libssl-dev libffi-dev \
python3-dev cargo
Check their installation guide for other distros and run airflow db init again

problem launching Jupyter notebook or Jupyter lab anaconda

I have a problem launching the Jupyter notebook on a remote Windows computer. running Jupyter from conda prompt returns WinError 1326 as below:
Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\traitlets\traitlets.py", line 535, in get
value = obj._trait_values[self.name]
KeyError: 'runtime_dir'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Anaconda3\Scripts\jupyter-notebook-script.py", line 10, in <module>
sys.exit(main())
File "D:\Anaconda3\lib\site-packages\jupyter_core\application.py", line 254, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "D:\Anaconda3\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
app.initialize(argv)
File "D:\Anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in inner
return method(app, *args, **kwargs)
File "D:\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 2127, in initialize
self.init_configurables()
File "D:\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1650, in init_configurables
connection_dir=self.runtime_dir,
File "D:\Anaconda3\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
return self.get(obj, cls)
File "D:\Anaconda3\lib\site-packages\traitlets\traitlets.py", line 538, in get
default = obj.trait_defaults(self.name)
File "D:\Anaconda3\lib\site-packages\traitlets\traitlets.py", line 1578, in trait_defaults
return self._get_trait_default_generator(names[0])(self)
File "D:\Anaconda3\lib\site-packages\jupyter_core\application.py", line 85, in _runtime_dir_default
ensure_dir_exists(rd, mode=0o700)
File "D:\Anaconda3\lib\site-packages\jupyter_core\utils\__init__.py", line 11, in ensure_dir_exists
os.makedirs(path, mode=mode)
File "D:\Anaconda3\lib\os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "D:\Anaconda3\lib\os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "D:\Anaconda3\lib\os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
[Previous line repeated 3 more times]
File "D:\Anaconda3\lib\os.py", line 223, in makedirs
mkdir(name, mode)
OSError: [WinError 1326] Username or password is incorrect: 'MY_SERVER_ADDRESS'
I tried changing some values in config file but no luck! please help me fix this problem
This might help:->
steps include:->
1-open cmd
2-paste the path of your Jupyter folder
3-write "Jupyter notebook" and press enter you will redirect to Jupyter
4-still not working check your python path is configured or not and then go to step1,2,3:->
upvote if it's helpful
or
you can made another folder jupyter folder and then configure python
and install jupyter notebook and use above steps.

Pyinstaller - Flask template not found "bootstrap/base.html"

I am trying to make a distributable of a flask application. Everything works fine when running locally. When an executable is generated with pyinstaller it gives me the error:
Traceback (most recent call last):
File "site-packages\flask\app.py", line 2446, in wsgi_app
File "site-packages\flask\app.py", line 1951, in full_dispatch_request
File "site-packages\flask\app.py", line 1820, in handle_user_exception
File "site-packages\flask\_compat.py", line 39, in reraise
File "site-packages\flask\app.py", line 1949, in full_dispatch_request
File "site-packages\flask\app.py", line 1935, in dispatch_request
File "app.py", line 39, in index
File "site-packages\flask\templating.py", line 140, in render_template
File "site-packages\flask\templating.py", line 120, in _render
jinja2.exceptions.TemplateNotFound: bootstrap/base.html
I am using the flask bootstrap as shown here.
create a new python file named 'hook-flask_bootstrap.py', inside of this paste the following:
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('flask_bootstrap')
Now when you run pyinstaller provide the path to this 'hook-flask_bootstrap.py' file:
--additional-hooks-dir=PATH (If relative path, just use .)

DAG started from airflow scheduler not finding values in airflow.cfg

I'm taking advantage of the fact that Airflow v1.7.1.3 provides access to airflow.cfg to place some configuration values there rather than embedded in the code. We added the following as the first lines of the airflow.cfg file:
[foo]
bar = foo
bar
In the foobarDAG.py class representing the DAG, I do the following:
from airflow.configuration import conf
…
def fooBar():
pass
foobarList = conf['foo']['bar'].split('\n')
foobarOperator = PythonOperator(
task_id='fooBar',
provide_context=True,
python_callable=fooBar,
op_args=[foobarList],
dag=dag)
Testing this manually from the Python prompt is easy:
>>> from foobarDAG import foobarList
…
>>> foobarList
['foo', 'bar']
That's just what I would expect from the information in airflow.cfg, above.
We've also performed a test on the DAG directly:
airflow test foobarDAG fooBar 10-19-2016
That doesn't report any problems.
The problem crops up when we try to use the scheduler to schedule that one DAG:
airflow scheduler -d foobarDAG >& foobar_log.txt
In the web UI, we see the following at the top of the "DAGS" section:
Broken DAG: [/path/to/…/foobarDAG.py] 'foo'
And in foobar_log.txt, here is the error message:
[2016-10-19 14:56:09,028] {models.py:250} ERROR - Failed to import: /path/to/foobarDAG.py
Traceback (most recent call last):
File "/path/to/airflow/models.py", line 247, in process_file
m = imp.load_source(mod_name, filepath)
File "/path/to/anaconda3/envs/foobarenv/lib/python3.5/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/path/to/foobarDAG.py", line 67, in <module>
foobarList = conf['foo']['bar'].split('\n')
File "/path/to/anaconda3/envs/foobarenv/lib/python3.5/configparser.py", line 956, in __getitem__
raise KeyError(key)
KeyError: 'foo'
So oddly it appears that the scheduler isn't retrieving the ['foo'] section from airflow.cfg and providing it to the DAG. Any idea why?
It turns out that everything was working properly, but the scheduler hadn't been restarted. The scheduler was apparently still using the old airflow.cfg which did not have the added section.

Resources