Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

ModuleNotFoundError: No module named 'librosa'

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
6 posts • Page 1 of 1
Author
Message
picarica
Guru
Guru
Posts: 366
Joined: Sat Aug 11, 2018 12:41 am

ModuleNotFoundError: No module named 'librosa'

  • Quote

Post by picarica » Tue Jun 04, 2024 8:45 am

where can i get librosa plugin? cant found it anywhere in repo, is it supported? or do i have to install it via pip
Top
rab0171610
l33t
l33t
Posts: 721
Joined: Sat Dec 24, 2022 1:41 am

  • Quote

Post by rab0171610 » Wed Jun 05, 2024 4:33 am

You would need to install it with pip. I am not sure how others here handle python stuff that are not available through portage. The recommended method is installing to a virtual environment (venv) but I usually use the brute force method for obscure modules by using --break-system-packages. I have not had issues but others here will probably have a strong opinion about it one way or another. You will have to wait for someone else to explain what the current best practice for that is on Gentoo.

If you were wanting to do it the proper way (ebuild), I modified an existing ebuild in my localrepo for a python package. After converting it for librosa, it appears to have installed correctly.

If you have or set up a local repository for ebuilds, this worked for me using a recent version of librosa:

dev-python/librosa/librosa-0.10.2.ebuild

Code: Select all

# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{10..12} )
inherit distutils-r1

DESCRIPTION="A python package for music and audio analysis."
HOMEPAGE="https://github.com/librosa/librosa"

LICENSE="GPL-3+"
SLOT="0"

if [[ "${PV}" == *9999* ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/librosa/librosa.git"
else
	SRC_URI="https://github.com/librosa/librosa/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"
	KEYWORDS="amd64"
	S="${WORKDIR}/${PN}-${PV}"
fi

RESTRICT="mirror"
IUSE=""
# pytest-xdist isn't really required but it helps speed up tests
BDEPEND="
	dev-python/orjson[${PYTHON_USEDEP}]
"

RDEPEND="
	${BDEPEND}
"

distutils_enable_tests pytest

src_prepare() {
	distutils-r1_python_prepare_all

}

python_test() {
	epytest -n auto
}

Someone else would have to improve upon this as it may also need dev-python/lazy-loader and possibly dev-python/numpy and dev-python/matplotlib as dependencies. Maybe there are others.

When opening up a python console, I typed:

Code: Select all

import librosa
followed by:

Code: Select all

librosa.show_versions()
Here is the output:

Code: Select all

INSTALLED VERSIONS
------------------
python: 3.12.3 (main, May 21 2024, 03:35:07) [GCC 13.2.1 20240113]

librosa: 0.10.2

audioread: None
numpy: 1.26.4
scipy: None
sklearn: None
joblib: None
decorator: None
numba: None
soundfile: None
pooch: None
soxr: None
typing_extensions: None
lazy_loader: 0.4
msgpack: None

numpydoc: None
sphinx: None
sphinx_rtd_theme: None
matplotlib: None
sphinx_multiversion: None
sphinx_gallery: None
mir_eval: None
ipython: None
sphinxcontrib.rsvgconverter: None
pytest: None
pytest_mpl: None
pytest_cov: None
samplerate: None
resampy: None
presets: None
packaging: 24.0
I don't know which of those you would need to also install for your use case.
Top
logrusx
Advocate
Advocate
User avatar
Posts: 3533
Joined: Thu Feb 22, 2018 2:29 pm

  • Quote

Post by logrusx » Wed Jun 05, 2024 5:27 am

rab0171610 wrote:You would need to install it with pip. I am not sure how others here handle python stuff that are not available through portage. The recommended method is installing to a virtual environment (venv) but I usually use the brute force method for obscure modules by using --break-system-packages. I have not had issues but others here will probably have a strong opinion about it one way or another. You will have to wait for someone else to explain what the current best practice for that is on Gentoo.

Code: Select all

 pip install --help

...

  --user                      Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for full
                              details.)
You just need to be careful which use you do that for. It's not a good idea to do it for root. This is kind of environment pollution if you're not careful with it.

Best Regards,
Georgi
Top
eschwartz
Developer
Developer
User avatar
Posts: 240
Joined: Sun Oct 29, 2023 4:27 pm

  • Quote

Post by eschwartz » Thu Jun 06, 2024 1:59 pm

pip install automatically implies --user if you run it as non-root, so the issue rarely comes up because nothing suggests that you should use "sudo pip".

(Do not ever use "sudo pip".)

That being said, the pip functionality of break-system-packages is broken and buggy by design. You need that flag even to install with --user despite that being user packages, not system packages.

You can add that option to a pip.conf configuration file so you don't need to type it in every time, though.
Top
Hu
Administrator
Administrator
Posts: 24398
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Thu Jun 06, 2024 3:24 pm

As I understand it, the Python rules for search paths mean that using pip install --user will affect the results of import lib run by that user, even when that import lib is from a system library. Thus, if you pip install --user portage==broken-version, then equery as your user will find the broken-version of portage and fail when it tries to use Portage libraries to support its query. As such, there is some value to preventing users from unknowingly installing packages into their account-level search path.
Top
eschwartz
Developer
Developer
User avatar
Posts: 240
Joined: Sun Oct 29, 2023 4:27 pm

  • Quote

Post by eschwartz » Thu Jun 06, 2024 3:40 pm

This is a trivially solvable problem and I have discussed it a few times with Sam/mgorny and griped a bit with upstream CPython as well.

From the Gentoo perspective, the way Gentoo packages pip and CPython to make pip behave this was was intended *solely* to prevent pip from overwriting portage managed files in /usr, and its effect on pip install --user is an unintended side effect as users are "allowed" to break their user install as long as portage run as root doesn't have issues.

It replaced a former downstream Gentoo-specific patch to pip itself that made pip error out when it detected it was run with the root UID, on the theory that using an upstream option even if it sucks and has bad side effects is better than maintaining patches.


I've now been waiting since November for an upstream PyPA project to merge patches which I need so I can improve Gentoo's gpep517 and solve this better.

(Unfortunately that involves getting PyPA to merge patches! Hence the wait times.)
Top
Post Reply

6 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic