Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building A Package - Major Errors

I am converting my python code into a package to make it easier to consume.

Its my first time writing a setup.py file, and I am running into an error that I can't seem to find anyone else getting online.

Here is my setup.py file:

from setuptools import setup

install_requires = [
    "pandas==0.23.4",
    "numpy==1.15.3",
]

#Folder Structure
"""
/bcrt
    .git
    /Models
    setup.py
    /bcrt
        controls.py
        phone_numbers.py
"""

setup(name='bcrt',
      version='0.1.0',
      install_requires=install_requires,
      author='JJFord3',
      author_email='[email protected]',
      packages = ['bcrt'],
      package_dir = {'bcrt',
                     'bcrt/bcrt'},
      package_data = {'bcrt':['Models/*.csv']},
      py_modules = ['controls.main',
                    'controls.load_model',
                    'controls.process_data',
                    'controls.Send_EMAIL',
                    'phone_numbers.main']
     )

When I try and run python setup.py install, I get this error:

running install
running bdist_egg
Traceback (most recent call last):
  File "setup.py", line 48, in <module>
    'phone_numbers.main']
...
AttributeError: 'set' object has no attribute 'get'

The phone_numbers.py file looks like this:

#List of Bad Phone Numbers
def main():
    Phone_Number_List = [
    '18008675309',
    '18005550123'
    ]
    return Phone_Number_List

Does anyone know why this is happening? I'm sure it is something fundamentally wrong with my code.

like image 376
JJFord3 Avatar asked Nov 23 '25 13:11

JJFord3


1 Answers

I think the reason for your error is a typo causing a set to be created instead of a dict:

Incorrect:

  package_dir = {'bcrt',
                 'bcrt/bcrt'},

Correct:

  package_dir = {'bcrt':
                 'bcrt/bcrt'},

The error message says that the given object (set) doesn't have a method 'get'. The setup function expects a dict (which has a 'get' attribute) as the package_dir parameter.

like image 138
Kevin Avatar answered Nov 26 '25 04:11

Kevin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!