Questions tagged [pkg-resources]
92 questions
25
votes
2 answers
Getting package version using pkg_resources?
What is the recommended way getting hold of the package version of a package in the $PYTHONPATH or sys.path?
I remember that the pkg_resource module has some functionality for this but I can not find any related information. Please don't point me to…
user2665694
21
votes
5 answers
How to serve static files in FastAPI
I am trying to serve static files that I have in a package_docs directory. When I open in the browzer:
http://127.0.0.1:8001/packages/docs/index.html , the page is running.
But I want to open the page: http://127.0.0.1:8001/packages/docs/
without…

Christy Nakou
- 393
- 1
- 2
- 14
10
votes
1 answer
pkg_resources.resource_stream fails on python3
I am trying to load a resource which is present in my project using pkg_resources but it just throws me an exception saying that it quote "Can't perform this operation for loaders without 'get_data()'". I am not sure if I am doing something wrong…

flazzarini
- 7,791
- 5
- 33
- 34
10
votes
1 answer
Why does my installed app handle pkg_resources.iter_entry_points differently than in source?
I have a Python app that looks for plugins via pkg_resources.iter_entry_points.
When run directly from source checkout, this will find anything in sys.path that fits the bill, including source checkouts that happen to have an applicable .egg-info…

Benjamin Pollack
- 27,594
- 16
- 81
- 105
10
votes
2 answers
Accessing files in python egg from inside the egg
The question is an attempt to get the exact instruction on how to do that. There were few attempts before, which don't seem to be full solutions:
solution to move the file inside the package
solution to read as zip
accessing meta info via…

Eugene Sajine
- 8,104
- 3
- 23
- 28
9
votes
2 answers
How to get installation directory using setuptools and pkg_ressources
I'm working on a package P with setuptools and pkg_resources,
where the package, after installation, needs to download some binaries and place them in a dedicated directory (P/bin/).
I'm trying to use pkg_ressources.resource_filename to get the…

aluriak
- 5,559
- 2
- 26
- 39
9
votes
3 answers
Why can't `virtualenv` find `pkg_resources`?
I'm trying to use virtualenv in Ubuntu to install a local virtual Python environment. When I run the shell command:
$ virtualenv ./virt_python
It throws an exception that it can't import pkg_resources. But when I open a Python shell and from…

Rich
- 12,068
- 9
- 62
- 94
8
votes
1 answer
How do a load a python package resource from the current distribution using pkg_resources?
I have a Python package with some css stylesheets which I have included as resources like so:
from setuptools import setup
setup(
package_data={
'my.package.name': ['*.css']
}
# ...
)
I would now like to load one of these…

Daniel Fortunov
- 43,309
- 26
- 81
- 106
8
votes
2 answers
The gyp==0.1 distribution was not found
My project doesn't compile due to a problem with the bson node.js module. I tried to make it manually and got an error - 'gyp==0.1' not found by a Python script:
pkg_resources.DistributionNotFound: The 'gyp==0.1' distribution was
not found and…

Peter G.
- 7,816
- 20
- 80
- 154
7
votes
2 answers
Parameters of resource_filename in pkg_resource in python
I don't understand how exactly pkg_resource.resource_filename() work and what are its parameters. I searched a lot on web but their official documentation does not cover it well. Can someone explain it?

Ayush Jain
- 316
- 4
- 11
6
votes
2 answers
How to access text file in project root from python package under `src/` directory
I want my package's version number to live in a single place where everything that needs it can refer to it.
I found several suggestions in this Python guide to Single Sourcing the Package Version and decided to try #4, storing it in a simple text…

Peter Henry
- 443
- 4
- 13
6
votes
0 answers
cx_freeze no module named 'pkg_resources'
I'm using Python 3.3.5 with cx-freeze 4.3.3 on windows 8.1.
I'm trying to cx_freeze a program that uses pkg_resources.
I initially had it in my setup file under packages, but when I tried to freeze it the processes stopped with an error Import…

I_do_python
- 1,366
- 4
- 16
- 31
6
votes
4 answers
How can I deal with python eggs for multiple platforms in one location?
We have a common python installation for all of our systems in order to ensure every system has the same python installation and to ease configuration issues. This installation is located on a shared drive. We also have multiple platforms that…

Philbert
- 131
- 7
6
votes
2 answers
Accessing python egg's own metadata
I've produced a python egg using setuptools and would like to access it's metadata at runtime. I currently got working this:
import pkg_resources
dist = pkg_resources.get_distribution("my_project")
print(dist.version)
but this would probably work…

Pēteris Caune
- 43,578
- 6
- 59
- 81
5
votes
2 answers
pylint doesn't like pkg_resources.resource_filename
In my script I use:
python
from pkg_resources import resource_filename
Both PyDev and pylint 0.23 complain about unresolved import here.
E0611 No name 'resource_filename' in module 'pkg_resources'
As I understand, this happens due to the fact…

yacoob
- 811
- 1
- 11
- 20