Skip to content

NameError: name 'pkg_resources' is not defined #57

@ChristopheH

Description

@ChristopheH

Hello,

I am trying to use bamnostic instead of pysam, but I meet several issues on this line using "pkg_resources".

import pkg_resources

  1. Install with : pip install bamnostic
>>> import bamnostic as bs
 UserWarning:C:\Users\XXX\AppData\Local\miniforge3\envs\bamnostic\Lib\site-packages\bamnostic\__init__.py:41: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  1. Install with : conda create -n bamnostic bamnostic
>>> import bamnostic as bs
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import bamnostic as bs
  File "C:\Users\XXX\AppData\Local\miniforge3\envs\bamnostic\Lib\site-packages\bamnostic\__init__.py", line 42, in <module>
    example_bam = pkg_resources.resource_filename('bamnostic', 'data/') + 'example.bam'
                  ^^^^^^^^^^^^^
NameError: name 'pkg_resources' is not defined

Workaround
I did replace

import pkg_resources
example_bam = pkg_resources.resource_filename('bamnostic', 'data/') + 'example.bam'

with

import os
example_bam = os.path.join(os.path.dirname(__file__), 'data','example.bam')

Is it the proper way to solve this issue according to you ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions