"AttributeError: 'module' object has no attribute" with installed package - python

I have a project with these contents:
proj
├── src
│ ├── scriptA.py
│ ├── scriptB.py
│ └── __init__.py
├── LICENCE
├── README.md
└── setup.py
I am following this guide to package this project for PiPY. The setup.py file looks like:
#!/usr/bin/python3
# coding=utf8
from setuptools import setup
setup(
name = "proj",
version = "0.2",
packages = ['src'],
install_requires=[],
entry_points={
'console_scripts': [
'scriptA=src:scriptA',
'scriptB=src:scriptB'
],
},
# metadata for upload to PyPI
author = "Luís",
author_email = "luis#mail.com",
description = "Some package",
license = "EUPL v1.1",
keywords = "pip package",
url = "https://some.place.com", # project home page, if any
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: European Union Public Licence 1.1 (EUPL 1.1)",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: GIS"
],
# could also include long_description, download_url, classifiers, etc.
)
The __init__.py file contains the following:
__all__ = ["scriptA", "scriptB"]
The scripts just print text messages. This is scriptA.py:
def main():
print ("This is scriptA!")
main()
The packages is building sucessfully:
$ python3 setup.py bdist_wheel --universal
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/src
copying src/scriptA.py -> build/lib/src
copying src/__init__.py -> build/lib/src
copying src/scriptB.py -> build/lib/src
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/src
copying build/lib/src/scriptA.py -> build/bdist.linux-x86_64/wheel/src
copying build/lib/src/__init__.py -> build/bdist.linux-x86_64/wheel/src
copying build/lib/src/scriptB.py -> build/bdist.linux-x86_64/wheel/src
running install_egg_info
running egg_info
creating proj.egg-info
writing proj.egg-info/PKG-INFO
writing top-level names to proj.egg-info/top_level.txt
writing entry points to proj.egg-info/entry_points.txt
writing dependency_links to proj.egg-info/dependency_links.txt
writing manifest file 'proj.egg-info/SOURCES.txt'
reading manifest file 'proj.egg-info/SOURCES.txt'
writing manifest file 'proj.egg-info/SOURCES.txt'
Copying proj.egg-info to build/bdist.linux-x86_64/wheel/proj-0.1.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/proj-0.1.dist-info/WHEEL
I then installed it in a Python 3 virtual environment:
$ source ~/.virtualenvs/test_p3/bin/activate
(test_p3)$ python setup.py install
running install
running bdist_egg
running egg_info
writing dependency_links to proj.egg-info/dependency_links.txt
writing proj.egg-info/PKG-INFO
writing entry points to proj.egg-info/entry_points.txt
writing top-level names to proj.egg-info/top_level.txt
reading manifest file 'proj.egg-info/SOURCES.txt'
writing manifest file 'proj.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/src
copying build/lib/src/scriptA.py -> build/bdist.linux-x86_64/egg/src
copying build/lib/src/__init__.py -> build/bdist.linux-x86_64/egg/src
copying build/lib/src/scriptB.py -> build/bdist.linux-x86_64/egg/src
byte-compiling build/bdist.linux-x86_64/egg/src/scriptA.py to scriptA.cpython-34.pyc
byte-compiling build/bdist.linux-x86_64/egg/src/__init__.py to __init__.cpython-34.pyc
byte-compiling build/bdist.linux-x86_64/egg/src/scriptB.py to scriptB.cpython-34.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying proj.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying proj.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying proj.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying proj.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying proj.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/proj-0.1-py3.4.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing proj-0.1-py3.4.egg
Copying proj-0.1-py3.4.egg to /home/desouslu/.virtualenvs/test_p3/lib/python3.4/site-packages
Adding proj 0.1 to easy-install.pth file
Installing scriptA script to /home/desouslu/.virtualenvs/test_p3/bin
Installing scriptB script to /home/desouslu/.virtualenvs/test_p3/bin
Installed /home/desouslu/.virtualenvs/test_p3/lib/python3.4/site-packages/proj-0.1-py3.4.egg
Processing dependencies for proj==0.1
Finished processing dependencies for proj==0.1
But when I run one of the scripts I get the following:
(test_p3)$ scriptA
Traceback (most recent call last):
File "/home/desouslu/.virtualenvs/test_p3/lib/python3.4/site-packages/pkg_resources.py", line 2051, in load
entry = getattr(entry,attr)
AttributeError: 'module' object has no attribute 'scriptA'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/desouslu/.virtualenvs/test_p3/bin/scriptA", line 9, in <module>
load_entry_point('proj==0.1', 'console_scripts', 'scriptA')()
File "/home/desouslu/.virtualenvs/test_p3/lib/python3.4/site-packages/pkg_resources.py", line 353, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/desouslu/.virtualenvs/test_p3/lib/python3.4/site-packages/pkg_resources.py", line 2321, in load_entry_point
return ep.load()
File "/home/desouslu/.virtualenvs/test_p3/lib/python3.4/site-packages/pkg_resources.py", line 2053, in load
raise ImportError("%r has no %r attribute" % (entry,attr))
ImportError: <module 'src' from '/home/desouslu/.virtualenvs/test_p3/lib/python3.4/site-packages/hex_utils-0.2-py3.4.egg/src/__init__.py'> has no 'scriptA' attribute
What is exactly causing this error?

In your case it looks for scriptA callable in module src.
Looking at the docs, entry_points should be defined like:
entry_points={
'console_scripts': [
'scriptA=src.scriptA:main_func',
'scriptB=src.scriptB:main_func'
],
},

You should declarate your classes in __init__.py follow link

Related

Building python package doesn't find requirements.txt

Its the first time that I have to use the content of an old git repository in the one that I'm actually working. I decided to try to create a Python Package of it to import in the new as a library (I am using gitlab).
I've searched info to do it but it is so hard to find a consistent solution.
I've first tried to build the package locally, by executing:
python setup.py bdist_wheel
And then:
python3 -m build
The package should build dependencies for wheel, but it crashes when trying to find the requirements.txt file.
I see previously that the command writes the egg-info files, creates the package, and copies files from local to the package:
(venv) acivit#odin:~/projects/mechanized-number-recognition$ python3 -m build
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
* Getting build dependencies for sdist...
running egg_info
writing acivit.mechanized_number_recognition.egg-info/PKG-INFO
writing dependency_links to acivit.mechanized_number_recognition.egg-info/dependency_links.txt
writing requirements to acivit.mechanized_number_recognition.egg-info/requires.txt
writing top-level names to acivit.mechanized_number_recognition.egg-info/top_level.txt
reading manifest file 'acivit.mechanized_number_recognition.egg-info/SOURCES.txt'
adding license file 'LICENSE.md'
writing manifest file 'acivit.mechanized_number_recognition.egg-info/SOURCES.txt'
* Building sdist...
running sdist
running egg_info
writing acivit.mechanized_number_recognition.egg-info/PKG-INFO
writing dependency_links to acivit.mechanized_number_recognition.egg-info/dependency_links.txt
writing requirements to acivit.mechanized_number_recognition.egg-info/requires.txt
writing top-level names to acivit.mechanized_number_recognition.egg-info/top_level.txt
reading manifest file 'acivit.mechanized_number_recognition.egg-info/SOURCES.txt'
adding license file 'LICENSE.md'
writing manifest file 'acivit.mechanized_number_recognition.egg-info/SOURCES.txt'
running check
creating acivit.mechanized_number_recognition-0.0.3
creating acivit.mechanized_number_recognition-0.0.3/config
creating acivit.mechanized_number_recognition-0.0.3/acivit.mechanized_number_recognition.egg-info
creating acivit.mechanized_number_recognition-0.0.3/models
creating acivit.mechanized_number_recognition-0.0.3/utils
creating acivit.mechanized_number_recognition-0.0.3/utils/wandb_logging
copying files to acivit.mechanized_number_recognition-0.0.3...
copying LICENSE.md -> acivit.mechanized_number_recognition-0.0.3
copying README.md -> acivit.mechanized_number_recognition-0.0.3
copying setup.py -> acivit.mechanized_number_recognition-0.0.3
copying config/__init__.py -> acivit.mechanized_number_recognition-0.0.3
copying config/modules_config.py -> acivit.mechanized_number_recognition-0.0.3/config
copying acivit.mechanized_number_recognition.egg-info/PKG-INFO -> acivit.mechanized_number_recognition-0.0.3/acivit.mechanized_number_recognition.egg-info
copying acivit.mechanized_number_recognition.egg-info/SOURCES.txt -> acivit.mechanized_number_recognition-0.0.3/acivit.mechanized_number_recognition.egg-info
copying acivit.mechanized_number_recognition.egg-info/dependency_links.txt -> acivit.mechanized_number_recognition-0.0.3/acivit.mechanized_number_recognition.egg-info
copying acivit.mechanized_number_recognition.egg-info/not-zip-safe -> acivit.mechanized_number_recognition-0.0.3/acivit.mechanized_number_recognition.egg-info
copying acivit.mechanized_number_recognition.egg-info/requires.txt -> acivit.mechanized_number_recognition-0.0.3/acivit.mechanized_number_recognition.egg-info
copying acivit.mechanized_number_recognition.egg-info/top_level.txt -> acivit.mechanized_number_recognition-0.0.3/acivit.mechanized_number_recognition.egg-info
copying models/__init__.py -> acivit.mechanized_number_recognition-0.0.3/models
copying models/common.py -> acivit.mechanized_number_recognition-0.0.3/models
copying models/experimental.py -> acivit.mechanized_number_recognition-0.0.3/models
copying models/yolo.py -> acivit.mechanized_number_recognition-0.0.3/models
copying utils/__init__.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/activations.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/add_nms.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/autoanchor.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/camera.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/datasets.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/general.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/google_utils.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/loss.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/metrics.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/plots.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/py_save.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/torch_utils.py -> acivit.mechanized_number_recognition-0.0.3/utils
copying utils/wandb_logging/__init__.py -> acivit.mechanized_number_recognition-0.0.3/utils/wandb_logging
copying utils/wandb_logging/log_dataset.py -> acivit.mechanized_number_recognition-0.0.3/utils/wandb_logging
copying utils/wandb_logging/wandb_utils.py -> acivit.mechanized_number_recognition-0.0.3/utils/wandb_logging
Writing acivit.mechanized_number_recognition-0.0.3/setup.cfg
Creating tar archive
removing 'acivit.mechanized_number_recognition-0.0.3' (and everything under it)
* Building wheel from sdist
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
* Getting build dependencies for wheel...
Traceback (most recent call last):
File "/home/acivit/projects/mechanized-number-recognition/venv/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/acivit/projects/mechanized-number-recognition/venv/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/acivit/projects/mechanized-number-recognition/venv/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/build-env-6rchc20e/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/build-env-6rchc20e/lib/python3.8/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "/tmp/build-env-6rchc20e/lib/python3.8/site-packages/setuptools/build_meta.py", line 484, in run_setup
super(_BuildMetaLegacyBackend,
File "/tmp/build-env-6rchc20e/lib/python3.8/site-packages/setuptools/build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 6, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'
ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel
The project structure is:
MechanizedNumberPackage
README
requirements.txt
utils
config
models
main.py
The setup.py file:
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
with open("requirements.txt", "r") as fh:
install_requires = fh.read()
setuptools.setup(
name="acivit.mechanized_number_recognition",
version="0.0.3",
author="Acivit",
description="`System to detect the Mechanized Number",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://gitlab.com/acivit/project/ai_systems/mechanized-number-recognition",
#  Disable zip_safe to allow compatibility with mypy.
# See: https://mypy.readthedocs.io/en/stable/installed_packages.html#making-pep-561-compatible-packages
zip_safe=False,
package_data={"mechanized_number_recognition": ["py.typed"]},
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
python_requires=">=3.6",
install_requires=install_requires,
)
Any idea why this happens? Or any other method to build the package?
Thanks
Making a wild guess that your MANIFEST.in does not have requirements.txt in include.. something like this:
include *.md LICENSE requirements.txt CHANGELOG

Installing matlab engine to call matlab function from python - python 3.7 is not supported causing import failure

I've done what every guide I have found does. I am in my anaconda enviroment and I have went to the directory where the setup.py is. I install it, then launch python, then try to import it and it says 3.7 is not supported even though it is in the supported list, and I am running 3.7:
(opt) vogtster#Vogtsters-Mini python % python setup.py build --build-base=$(mktemp -d) install --user
/Users/vogtster/opt/anaconda3/envs/opt/lib/python3.7/site-packages/setuptools/dist.py:534: UserWarning: The version specified ('R2022a') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
"details." % version
running build
running build_py
creating /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib
creating /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab
copying dist/matlab/__init__.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab
creating /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/fevalfuture.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/matlabengine.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/basefuture.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/__init__.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/matlabfuture.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/futureresult.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/enginehelper.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/engineerror.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
copying dist/matlab/engine/enginesession.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine
running install
/Users/vogtster/opt/anaconda3/envs/opt/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
setuptools.SetuptoolsDeprecationWarning,
/Users/vogtster/opt/anaconda3/envs/opt/lib/python3.7/site-packages/setuptools/command/easy_install.py:147: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
EasyInstallDeprecationWarning,
/Users/vogtster/opt/anaconda3/envs/opt/lib/python3.7/site-packages/pkg_resources/__init__.py:125: PkgResourcesDeprecationWarning: R2022a is an invalid version and will not be supported in a future release
PkgResourcesDeprecationWarning,
running bdist_egg
running egg_info
writing dist/matlabengineforpython.egg-info/PKG-INFO
writing dependency_links to dist/matlabengineforpython.egg-info/dependency_links.txt
writing top-level names to dist/matlabengineforpython.egg-info/top_level.txt
/Users/vogtster/opt/anaconda3/envs/opt/lib/python3.7/site-packages/setuptools/command/egg_info.py:627: SetuptoolsDeprecationWarning: Custom 'build_py' does not implement 'get_data_files_without_manifest'.
Please extend command classes from setuptools instead of distutils.
SetuptoolsDeprecationWarning
reading manifest file 'dist/matlabengineforpython.egg-info/SOURCES.txt'
writing manifest file 'dist/matlabengineforpython.egg-info/SOURCES.txt'
installing library code to /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg
running install_lib
creating /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64
creating /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg
creating /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/__init__.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab
creating /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/fevalfuture.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/matlabengine.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/basefuture.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/__init__.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/matlabfuture.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/_arch.txt -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/futureresult.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/enginehelper.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/engineerror.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
copying /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/lib/matlab/engine/enginesession.py -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/__init__.py to __init__.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/fevalfuture.py to fevalfuture.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/matlabengine.py to matlabengine.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/basefuture.py to basefuture.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/__init__.py to __init__.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/matlabfuture.py to matlabfuture.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/futureresult.py to futureresult.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/enginehelper.py to enginehelper.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/engineerror.py to engineerror.cpython-37.pyc
byte-compiling /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/matlab/engine/enginesession.py to enginesession.cpython-37.pyc
creating /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying dist/matlabengineforpython.egg-info/PKG-INFO -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying dist/matlabengineforpython.egg-info/SOURCES.txt -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying dist/matlabengineforpython.egg-info/dependency_links.txt -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying dist/matlabengineforpython.egg-info/top_level.txt -> /var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
matlab.__pycache__.__init__.cpython-37: module references __file__
matlab.__pycache__.__init__.cpython-37: module references __path__
matlab.engine.__pycache__.__init__.cpython-37: module references __file__
creating 'dist/matlabengineforpython-R2022a-py3.7.egg' and adding '/var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg' to it
removing '/var/folders/2t/1hqm8qtd78xb9grhqz2023_w0000gn/T/tmp.CcDlA6kb/bdist.macosx-10.9-x86_64/egg' (and everything under it)
Processing matlabengineforpython-R2022a-py3.7.egg
removing '/Users/vogtster/.local/lib/python3.7/site-packages/matlabengineforpython-R2022a-py3.7.egg' (and everything under it)
creating /Users/vogtster/.local/lib/python3.7/site-packages/matlabengineforpython-R2022a-py3.7.egg
Extracting matlabengineforpython-R2022a-py3.7.egg to /Users/vogtster/.local/lib/python3.7/site-packages
matlabengineforpython R2022a is already the active version in easy-install.pth
Installed /Users/vogtster/.local/lib/python3.7/site-packages/matlabengineforpython-R2022a-py3.7.egg
Processing dependencies for matlabengineforpython===R2022a
Finished processing dependencies for matlabengineforpython===R2022a
(opt) vogtster#Vogtsters-Mini python % python
Python 3.7.13 (default, Mar 28 2022, 07:24:34)
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matlab.engine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/vogtster/.local/lib/python3.7/site-packages/matlabengineforpython-R2022a-py3.7.egg/matlab/__init__.py", line 200, in <module>
success = get_dirs_from_arch_file_without_import()
File "/Users/vogtster/.local/lib/python3.7/site-packages/matlabengineforpython-R2022a-py3.7.egg/matlab/__init__.py", line 159, in get_dirs_from_arch_file_without_import
_PYTHONVERSION = get_python_version()
File "/Users/vogtster/.local/lib/python3.7/site-packages/matlabengineforpython-R2022a-py3.7.egg/matlab/__init__.py", line 150, in get_python_version
raise EnvironmentError("Python %s is not supported." % _version)
OSError: Python 3_7 is not supported.
>>>
This is the directory I am in when I call the python setup.py install - is this wrong somehow?
/Users/vogtster/Desktop/MATLAB_R2022a.app/extern/engines/python
File "/Users/vogtster/.local/lib/python3.7/site-packages/matlabengineforpython-R2022a-py3.7.egg/matlab/__init__.py", line 150, in get_python_version
It was looking locally for some reason. I deleted this, downgraded to R2021a and not everything works great.

I try to build a universal wheel, but it rolls away

I run:
python3 setup.py bdist_wheel --universal
It says it's making all sorts of stuff, but then the resulting directory (build/bdist.macosx-10.10-x86_64) is empty. Where did my wheel roll away to?t
Edit
I now see that I'm trying to look at the temp output. When I specify -d, sure enough, there's a wheel in the designated location. Does -d have a default? Has my wheel been parked under my nose all along?
running bdist_wheel
running build
running build_py
running egg_info
writing dependency_links to rosapi_launcher.egg-info/dependency_links.txt
writing top-level names to rosapi_launcher.egg-info/top_level.txt
writing rosapi_launcher.egg-info/PKG-INFO
writing requirements to rosapi_launcher.egg-info/requires.txt
reading manifest file 'rosapi_launcher.egg-info/SOURCES.txt'
writing manifest file 'rosapi_launcher.egg-info/SOURCES.txt'
installing to build/bdist.macosx-10.10-x86_64/wheel
running install
running install_lib
creating build/bdist.macosx-10.10-x86_64/wheel
creating build/bdist.macosx-10.10-x86_64/wheel/launcher
copying build/lib/launcher/__init__.py -> build/bdist.macosx-10.10-x86_64/wheel/launcher
copying build/lib/launcher/containers.py -> build/bdist.macosx-10.10-x86_64/wheel/launcher
copying build/lib/launcher/launcher.py -> build/bdist.macosx-10.10-x86_64/wheel/launcher
copying build/lib/launcher/prop_file.py -> build/bdist.macosx-10.10-x86_64/wheel/launcher
copying build/lib/launcher/properties.py -> build/bdist.macosx-10.10-x86_64/wheel/launcher
copying build/lib/launcher/snapshots.py -> build/bdist.macosx-10.10-x86_64/wheel/launcher
copying build/lib/launcher/utils.py -> build/bdist.macosx-10.10-x86_64/wheel/launcher
running install_egg_info
Copying rosapi_launcher.egg-info to build/bdist.macosx-10.10-x86_64/wheel/rosapi_launcher-0.0.1-py3.4.egg-info
running install_scripts
creating build/bdist.macosx-10.10-x86_64/wheel/rosapi_launcher-0.0.1.dist-info/WHEEL
My setup.py is:
from setuptools import setup
import io
import os
import launcher
here = os.path.abspath(os.path.dirname(__file__))
# noinspection PyPackageRequirements
def read(*filenames, **kwargs):
encoding = kwargs.get('encoding', 'utf-8')
sep = kwargs.get('sep', '\n')
buf = []
for filename in filenames:
with io.open(filename, encoding=encoding) as f:
buf.append(f.read())
return sep.join(buf)
long_description = read('README.txt', 'CHANGES.txt')
setup(
name='rosapi-launcher',
version=launcher.__version__,
install_requires=['pyaml',
'boto3'
],
description='RosAPI launcher',
long_description=long_description,
packages=['launcher'],
include_package_data=True,
platforms='any',
classifiers = [
'Programming Language :: Python',
'Natural Language :: English'
]
)
The answer I found is this:
python3 setup.py bdist_wheel
doesn't write the results anyplace I can find them.
python3 setup.py bdist_wheel -d .
writes it, well, right here.
If I got you right, you search for resulting .whl file in ./build/... directory. But resulting files, both source distribution and wheel, usually by default get created in the ./dist/ directory, which is located near the build directory. Have you searched there?

setuptools removes the binary files , but keeps them in the tar

When i do
python setup.py bdist
for my python project folder.I find that it creates the dist, build folder but after it creates the egg/tar it deletes the binary.
How do i keep the binary files? I can see that it removes the build folder at the end.
running bdist
running bdist_dumb
running build
running build_py
creating build
creating build/lib
creating build/lib/my_project_folder
copying my_project_folder/__init__.py -> build/lib/my_project_folder
copying my_project_folder/my_script.py -> build/lib/my_project_folder
installing to build/bdist.linux-x86_64/dumb
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/dumb
creating build/bdist.linux-x86_64/dumb/usr
creating build/bdist.linux-x86_64/dumb/usr/lib
creating build/bdist.linux-x86_64/dumb/usr/lib/python2.6
creating build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages
creating build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder
copying build/lib/my_project_folder/__init__.py -> build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder
copying build/lib/my_project_folder/my_script.py -> build/bdist.linux-
byte-compiling build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder/my_script.py to my_script.pyc
running install_egg_info
running egg_info
creating my_project_folder.egg-info
writing requirements to my_project_folder.egg-info/requires.txt
writing my_project_folder.egg-info/PKG-INFO
writing top-level names to my_project_folder.egg-info/top_level.txt
writing dependency_links to my_project_folder.egg-info/dependency_links.txt
writing requirements to my_project_folder.egg-info/requires.txt
writing my_project_folder.egg-info/PKG-INFO
writing top-level names to my_project_folder.egg-info/top_level.txt
writing dependency_links to my_project_folder.egg-info/dependency_links.txt
writing manifest file 'my_project_folder.egg-info/SOURCES.txt'
reading manifest file 'my_project_folder.egg-info/SOURCES.txt'
writing manifest file 'my_project_folder.egg-info/SOURCES.txt'
Copying my_project_folder.egg-info to build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder-1.0.0_SNAPSHOT-py2.6.egg-info
running install_scripts
creating /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist
tar -cf /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist/my_project-v1-1.0.0-SNAPSHOT.linux-x86_64.tar .
gzip -f9 /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist/my_project-v1-1.0.0-SNAPSHOT.linux-x86_64.tar
tar -cf /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist/my_project-v1-1.0.0-SNAPSHOT.linux-x86_64.tar .
gzip -f9 /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist/my_project-v1-1.0.0-SNAPSHOT.linux-x86_64.tar
removing 'build/bdist.linux-x86_64/dumb' (and everything under it)
The problem i am trying to solve is to create a tar file of ONLY the binaries.
As of now able I am able to create the tar file with both *.py and *.pyc files(this comes by default with bdist command) I understand this is the feature of bdist command.
But i dont want the .py file in the end tar.
As long as i can get the access to the *.pyc files i can create the tar myself but setuptools doesnt let me keep it.
do both.
python setup.py bdist build
or
python setup.py bdist
python setup.py build

Problem using MySQLdb on OSX: symbol not found _mysql_affected_rows

This is related to a previous question.
However, the main posted solution there is not working for me. I'm on Snow Leopard, using the 32-bit 5.1.49 MySQL dmg install. I'm using the built in python (apparently, as noted in the comments, my Python version is different), which appears to be 2.6.5 32-bit:
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxint
2147483647
I've downloaded MySQL-python 1.2.3 from the usual location and changed site.cfg so that mysql_config points to the right place and the registry_key directive is commented out. The packages seems to build and install just fine:
caywork:MySQL-python-1.2.3 carl$ python setup.py clean
running clean
caywork:MySQL-python-1.2.3 carl$ python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.6/MySQLdb
running build_ext
caywork:MySQL-python-1.2.3 carl$ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.3-fat/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.6/MySQLdb
running build_ext
creating build/bdist.macosx-10.3-fat/egg
copying build/lib.macosx-10.3-fat-2.6/_mysql.so -> build/bdist.macosx-10.3-fat/egg
copying build/lib.macosx-10.3-fat-2.6/_mysql_exceptions.py -> build/bdist.macosx-10.3-fat/egg
creating build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/__init__.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/connections.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
creating build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/CR.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/ER.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/converters.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/cursors.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/release.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.6/MySQLdb/times.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
byte-compiling build/bdist.macosx-10.3-fat/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/times.py to times.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.macosx-10.3-fat/egg/_mysql.py to _mysql.pyc
creating build/bdist.macosx-10.3-fat/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.3-fat/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO
writing build/bdist.macosx-10.3-fat/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg' and adding 'build/bdist.macosx-10.3-fat/egg' to it
removing 'build/bdist.macosx-10.3-fat/egg' (and everything under it)
Processing MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg
Removing /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg
Copying MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg to /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
MySQL-python 1.2.3 is already the active version in easy-install.pth
Installed /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg
Processing dependencies for MySQL-python==1.2.3
Finished processing dependencies for MySQL-python==1.2.3
But when I try to use it, I get this:
caywork:MySQL-python-1.2.3 carl$ python -c "import MySQLdb"
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg/_mysql.pyc, but /Users/carl/Source/MySQL-python-1.2.3 is being added to sys.path
Traceback (most recent call last):
File "", line 1, in
File "MySQLdb/__init__.py", line 19, in
import _mysql
File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 7, in
File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/carl/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Users/carl/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg-tmp/_mysql.so
Expected in: dynamic lookup
All I can find on the web are older examples of this problem, along with numerous rants about how hard it is to get MySQL-python working on OSX. If anyone can help with this, I would greatly appreciate it!!
The only (admittedly kludgy) solution that I ended up getting to work was to use MySQL-python-1.2.2 after applying this patch, cobbled together from advice found here (http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/) and here (http://flo.nigsch.com/?p=62). Sorry for the lack of links but I don't have enough rep points to post more than one link.

Categories

Resources