buildroot package using scanpypi: ImportError: No module named 'setup' - python

I want to install some python packages ( importlib_metadata threadpoolctl) from source. They have pyproject.toml setup.cfg files, but there's no setup.py file. So when I try to install them, they give the same errors:
Traceback (most recent call last):
File "utils/scanpypi", line 750, in <module>
main()
File "utils/scanpypi", line 698, in main
package.load_setup()
File "utils/scanpypi", line 300, in load_setup
s_file, s_path, s_desc = imp.find_module('setup', [self.tmp_extract])
File "/usr/lib/python3.8/imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named 'setup'
Can I get some help, pls?

Your package uses PEP517 rather than setuptools or distutils. Support for PEP517 was added to Buildroot in 2022.05. Make sure you have a recent Buildroot version and set PYTHON_FOO_SETUP_TYPE to flit. See the manual for details.
Support for PEP517 was not yet added to the scanpypi utility, but there's a patch for it.

Related

PyScript ModuleNotFoundError: No module named '_lzma'

Piggybacking off a previous question that I submitted: Using WordNet with PyScript
I'm trying to install WordNet in PyScript using
await micropip.install('https://files.pythonhosted.org/packages/ce/f1/53b07100f5c3d41fd33fc78ebb9e99d736b0460ced8acff94840311ffc60/wn-0.9.1-py3-none-any.whl')
This gives me the error:
JsException(PythonError: Traceback (most recent call last):
File "/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception
File "/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None)
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 500, in eval_code_async await CodeRunner(
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 353, in run_async await coroutine File "", line 14, in
File "/lib/python3.10/site-packages/wn/init.py", line 47, in from wn._add import add, remove File "/lib/python3.10/site-packages/wn/_add.py", line 21, in from wn.project import iterpackages
File "/lib/python3.10/site-packages/wn/project.py", line 12, in import lzma
File "/lib/python3.10/lzma.py", line 27, in from _lzma import * ModuleNotFoundError: No module named '_lzma' )
Looking at some questions related to the "ModuleNotFoundError: No module named '_lzma'", the idea generally seems to be that it is an issue related to the Python installation. However, I am not sure how to go about resolving this within PyScript.
Any clues on what I did wrong/what I should do?
lzma is currently not included in Pyodide Python builds to reduce download size. Lzma remains an optional module, so the package should not fail if it's missing. You can report this issue to https://github.com/goodmami/wn
Meanwhile a temporary workaround is to remove that lzma import in wn, create a new python wheel with,
pip install build
python -m build
and install that with micropip by providing the URL.
It's possible that we may add lzma module in Pyodide the future pyodide#2937

`No module named nose_parameterized` during theano installation

At the moment I am trying to install theano on my ubuntu 16.04 system with cuda support. The installation process itself went well until I tried to test the installation:
python -c "import theano; theano.test()"
The last few lines of the output were:
======================================================================
ERROR: Failure: ImportError (No module named nose_parameterized)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/theano/tests/test_rop.py", line 16, in <module>
from theano.tests import unittest_tools as utt
File "/home/myUser/anaconda2/lib/python2.7/site-packages/theano/tests/unittest_tools.py", line 7, in <module>
from nose_parameterized import parameterized
ImportError: No module named nose_parameterized
----------------------------------------------------------------------
Ran 408 tests in 13.085s
FAILED (SKIP=26, errors=80)
These were preceded by approximately 20 blocks with what appears to be different tests failing on exactly the same top 3 lines in the stacktrace. The code where the final occurs looks like this (with added line numbers):
411. # FIXME: to support module.name names,
412. # do what resolve-name does and keep trying to
413. # import, popping tail of module into addr.call,
414. # until we either get an import or run out of
415. # module parts
416. try:
417. module = self.importer.importFromPath(
418. addr.filename, addr.module)
419. finally:
420. self.config.plugins.afterImport(
421. addr.filename, addr.module)
While searching for a solution I came across:
Error running nosetests
I tried the solution proposed there:
sudo pip install nose-parameterized
However this had no effect. Does anyone know what else could be causing this error?
edit: so I reinstalled theano to make the problem more reproducible. I installed theano using the instructions found here, so I used:
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git
sudo pip install Theano
Then I used:
nosetests theano
The last few lines of the output of this are almost the same as earlier:
======================================================================
ERROR: Failure: ImportError (No module named nose_parameterized)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/myUser/.local/lib/python2.7/site-packages/theano/tests/test_rop.py", line 16, in <module>
from theano.tests import unittest_tools as utt
File "/home/myUser/.local/lib/python2.7/site-packages/theano/tests/unittest_tools.py", line 7, in <module>
from nose_parameterized import parameterized
ImportError: No module named nose_parameterized
----------------------------------------------------------------------
Ran 457 tests in 160.608s
FAILED (SKIP=24, errors=95)
edit 2: I thought it might be a python-version issue. When I try:
python -V
I get:
Python 2.7.12 :: Anaconda 4.2.0 (64-bit)
And the following folders exist:
/usr/local/lib/python2.7/dist-packages/nose_parameterized
So, that shouldn't be a problem as far as I can see. However when I try:
python2.7 -c "import nose_parameterized"
I get:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named nose_parameterized
Found the problem, anaconda was looking in its own folder. So to solve, I did:
conda install nose-parameterized
The following works for me:
pip install nose-parameterized

Package works in /usr/local/lib but does not at /usr/lib

When I install a package 'python-brick-cinderclient-ext' from sources it works. But when I try to install it from .deb package that I've built, I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/brick_cinderclient_ext/__init__.py", line 30, in <module>
'brick-python-cinderclient-ext').version_string()
File "/usr/lib/python2.7/dist-packages/pbr/version.py", line 457, in version_string
return self.semantic_version().brief_string()
File "/usr/lib/python2.7/dist-packages/pbr/version.py", line 452, in semantic_version
self._semantic = self._get_version_from_pkg_resources()
File "/usr/lib/python2.7/dist-packages/pbr/version.py", line 439, in _get_version_from_pkg_resources
result_string = packaging.get_version(self.package)
File "/usr/lib/python2.7/dist-packages/pbr/packaging.py", line 668, in get_version
raise Exception("Versioning for this project requires either an sdist"
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed?
But when I've move the code in the same location that it installs with python setup.py install (from the /usr/lib/python2.7/dist-packages/ to /usr/local/lib/python2.7/dist-packages/) then it worked fine! Why is this happening?
The problem was in the wrong name for pbr.version module. There is brick-python-cinderclient-ext instead of python-brick-cinderclient-ext in the __init__.py file. So, it's a reason why pbr could not get the version of this package -> It's just could not find the version of such package in the egg.info. I've fixed it with the patch for __init__.py file with renaming brick-python-cinderclient-ext to python-brick-cinderclient-ext.

How Do I Ensure That All Modules Are Imported From Same Location Within Virtualenv

I am running python based software that requires a virtualenv with various additional python packages installed therein. Here are the install instructions:
Clone the repository to a shared filesysem on a cluster
>git clone https://github.com/jgurtowski/nanocorr
>cd nanocorr
Create a virtual environment to install python dependencies
>virtualenv nanocorr_ve
>source nanocorr_ve/bin/activate
install the following packages using pip:
pip install git+https://github.com/cython/cython
pip install numpy
pip install h5py
pip install git+https://github.com/jgurtowski/pbcore_python
pip install git+https://github.com/jgurtowski/pbdagcon_python
pip install git+https://github.com/jgurtowski/jbio
pip install git+https://github.com/jgurtowski/jptools
#Finally install the nanocorr package itself
> python setup.py install
I achieved this with no problems. However, While running the software, I found that it was failing with the following traceback.
(nanocorr_ve)[nanocorr_test]$ correctOxford
Traceback (most recent call last):
File "/local/workdir/malonge/nanocorr_test/nanocorr/nanocorr_ve/bin/correctOxford", line 9, in <module>
load_entry_point('jptools==0.1', 'console_scripts', 'correctOxford')()
File "/local/workdir/malonge/nanocorr_test/nanocorr/nanocorr_ve/lib/python2.7/site- packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/local/workdir/malonge/nanocorr_test/nanocorr/nanocorr_ve/lib/python2.7/site- packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/local/workdir/malonge/nanocorr_test/nanocorr/nanocorr_ve/lib/python2.7/site- packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/local/workdir/malonge/nanocorr_test/nanocorr/nanocorr_ve/lib/python2.7/site- packages/pkg_resources/__init__.py", line 2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/local/workdir/malonge/nanocorr_test/nanocorr/nanocorr_ve/lib/python2.7/site- packages/jptools/correct.py", line 21, in <module>
from pbtools.pbdagcon.q_sense import output_dag_info
File "/local/workdir/malonge/nanocorr_test/nanocorr/nanocorr_ve/lib/python2.7/site- packages/pbtools/pbdagcon/q_sense.py", line 50, in <module>
from pbcore.io import FastaReader
File "/programs/python/lib/python2.7/site-packages/pbcore-1.0.0- py2.7.egg/pbcore/io/__init__.py", line 31, in <module>
from .BasH5IO import *
File "/programs/python/lib/python2.7/site-packages/pbcore-1.0.0- py2.7.egg/pbcore/io/BasH5IO.py", line 37, in <module>
import h5py, numpy as np, os.path as op
File "/programs/python/lib/python2.7/site-packages/h5py-2.5.0-py2.7-linux- x86_64.egg/h5py/__init__.py", line 13, in <module>
from . import _errors
ImportError: /programs/python/lib/python2.7/site-packages/h5py-2.5.0-py2.7-linux-x86_64.egg/h5py/_errors.so: undefined symbol: PyUnicodeUCS2_DecodeUTF8
I have found details as to the specific error itself, but I think the source of the problem is that the traceback clearly shows a transition from modules being imported from the /local virtualenv site-packages to another site-packages directory in /programs.
My question is the following: Given that I have the same python packages installed in two separate places, 1 in the system wide location and one in virtualenv, how do I ensure that other programs properly import all modules from within the same virtualenv sit-packages directory. I thought this would have been done automatically. I am not 100% sure that this is the sole reason for the error, but being able to fix this would help me to further debug.
It depends on how you set up your env. virtualenv has a flag option that forces it to not use the system site packages
virtualenv --no-site-packages my_env
It is the default behavior for recent versions (>=1.7).
If you've defined a PYTHONPATH environment variable, that will affect your virtualenv environment as well.

Updated setuptools using easy_install -U, now there is a distribution error

I updated setuptools using:
easy_install -U setuptool
This ran fine. I then realized I did not want to use the most recent version of setuptools and deleted setuptools-18.3.2-py2.6.egg file from /usr/lib/python2.6/site-packages. After I did this I am getting the following errors when trying to install anything using easy_install shown below.
easy_install ReviewBoard-1.7.6-py2.6
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2659, in <module>
parse_requirements(__requires__), Environment()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: setuptools>=0.7
Looks like ReviewBoard needs setuptools as a dependency. When you ran easy_install ReviewBoard-1.7.6-py2.6, it would have detected that this dependency is already installed but actually it wasn't.
One reason could be that deleting the .egg file was not the complete process of getting rid of a package installed with easy_install. You also need to remove the corresponding line from site-packages/easy-install.pth. Refer: https://stackoverflow.com/a/1233282/4045754

Categories