Questions tagged [pkg-resources]
92 questions
5
votes
0 answers
Add an entry point at runtime in Python
I want to use setuptools entry points to subscribe groups of methods to messages coming from a communication channel.
That is very easy to do by declaring all entry points in your setup.py. But I'm not sure if I'll be able to add more entry points…

SCGH
- 887
- 8
- 13
5
votes
0 answers
Why can't I simply import pylint?
I've just installed pylint via the Cygwin package installer, and can run it from the bash command line on any .py file. But if I try to programatically import it inside a Python session, it fails:
>>> import pylint
Traceback (most recent call…

textral
- 1,029
- 8
- 13
5
votes
2 answers
how to load resource file while running python unittest using twisted trial
Problem
As part of python unittest, some input json files are to be loaded which exists under 'data' directory which resides in the same directory of test py file.
'pkg_resources' is used for this purpose.
It works fine when the unittest are running…

Durai Bose
- 51
- 4
5
votes
1 answer
Python: Writing to files within packages?
Using this general structure:
setup.py
/package
__init__.py
project.py
/data
client.log
I have a script that saves a list of names to client.log, so I don't have to reinitialize that list each time I need access to it or run the…

Insarov
- 971
- 1
- 10
- 15
4
votes
1 answer
python : multiple library versions at run time with pkg_resources (pkg_resources.VersionConflict error)
I'm trying to use two different releases of a same library (installed with easy_install --multi-version) from within the same python script. The general idea is illustrated in the code below.
If I call each version independently, everything is fine.…

Oliver Henriot
- 181
- 1
- 10
4
votes
2 answers
AnalysisException: Path does not exist: dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data;
I am packing the following code in a whl file:
from pkg_resources import resource_filename
def path_to_model(anomaly_dir_name: str, data_path: str):
filepath = resource_filename(anomaly_dir_name, data_path)
return filepath
def…

user3868051
- 1,147
- 2
- 22
- 43
4
votes
1 answer
Python pkg_resources and file access in packages
I'm building my first python package (which I then install with pip) and I need to use some non-python files. In these answers, it is explained that I should use the pkg_resources function. But I can't figure out a working example. Let say I have…

Robin
- 1,531
- 1
- 15
- 35
4
votes
3 answers
How do I get a Python distribution URL?
In their setup.py Python packages provides some information.
This information can then be found in the PKG_INFO file of the egg.
How can I access them once I have installed the package?
For instance, if I have the following…

Natim
- 17,274
- 23
- 92
- 150
4
votes
1 answer
How to load json from resource_stream in python 3
I'm trying to use to use resource_stream from pkg_resources in conjunction with json.load and am having problem in python 3 that were not present in python 2.
When I try to run the following command, I get the error:
loaded_json =…

Luke
- 6,699
- 13
- 50
- 88
3
votes
1 answer
Custom icon for .pkg file on Lion OSX
I have created a package using PackageMaker and want to change the default icon for .pkg file.
After some googling, seticon utility from here http://sveinbjorn.org/osxutils_docs solved my problem for all OSX-es except the latest Lion 10.7 (Kernel…

Cyril
- 159
- 3
- 16
3
votes
1 answer
Entry Points and Console Scripts Without 'pkg_resources'?
When I install pip (e.g. with venv), the /bin/pip is the following:
#!"/bin/python"
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] =…

Alexander Shukaev
- 16,674
- 8
- 70
- 85
3
votes
0 answers
Python - How to import module from .so file from egg file without using an absolute file path
I built the pyahocorasick library with python setup.py bdist_egg command and uploaded it onto Spark for my PySpark job.
However, the .so file inside pyahocorasick can't be imported through pkg_resources.resource_filename() method on Spark cluster…

GZ92
- 151
- 1
- 10
3
votes
1 answer
Python pkg_resources.get_distribution alternative
I have some code that's extremely slow, I've traced it back to the use of pkg_resources.get_distribution, I'm doing this:
# ...
pkg_resources.get_distribution(module_name).version
Is there an alternative library/method I can use that does the same…

KX68C4qxM51mtdzex7O8iMPU
- 153
- 6
3
votes
1 answer
Open file in universal-newline mode when using pkg_resources?
I am processing a CSV file and have the following working code:
reader = csv.reader(open(filename, 'rU'), dialect='excel')
header = reader.next()
However, to be compatible with elsewhere in the codebase, I need to use a file object using…

AP257
- 89,519
- 86
- 202
- 261
3
votes
2 answers
pkg_resources doesn't extract files from python egg
I created a python egg by running python setup.py bdist_egg from this folder:
SensorDisplay/
--- sensor_display/
----- __init__.py
----- can.py
----- sensor_display.py
----- data/
--------- sensor_param.txt
--- setup.py
in file setup.py, I have:
…

sarah vb
- 149
- 2
- 12