0

I have made python package from https://github.com/raamana/pyradigm and uploaded it to pip using the following commands (after following the instructions on pypi, etc):

python setup.py sdist bdist_wheel
twine upload dist/*

In theory, now one should be able to do

pip install pyradigm

(which I can confirm works) and then do the following in a Python file:

from pyradigm import MLDataset

to use the class MLDataset from pyradigm


Unfortunately it's not the case, as Python is throwing the following ImportError which is fairly non-specific:

In [1]: from pyradigm import MLDataset
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-4ad7330da13e> in <module>()
----> 1 from pyradigm import MLDataset

ImportError: cannot import name MLDataset

I can confirm that

  1. I was able to install pyradigm via pip on a new system
  2. both pip and python are able to find the package (installed in site-packages), as they auto-fill both the module name (pyradigm and class name MLDataset).

The setup.py in pyradigm is this:

#!/usr/bin/env python
import os

from setuptools import setup, find_packages

# Utility function to read the README file.
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(name='pyradigm',
      version='0.1.1.2',
      description='Python-based data structure to improve handling of datasets in machine learning workflows',
      long_description=read('README.md'),
      keywords='machine learning, test dataset, python, workflow, provenance, data structure',
      author='Pradeep Reddy Raamana',
      url='https://github.com/raamana/pyradigm',
      packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), # packages=['pyradigm'],
      install_requires=['numpy', 'setuptools'],
     )

The package has only 3 files:

__init__.py      pyradigm.py      test_pyradigm.py

with the __init__.py containing the only a single line:

__all__ = [ 'pyradigm', 'MLDataset' ]

Any help in understanding in this error, and ways to fix it would be appreciated. Thanks.

Dušan Maďar
  • 9,269
  • 5
  • 49
  • 64
  • Did you tried `pip install pyradigm --upgrade?` Do you have on your computer another version of python? – nick_gabpe Mar 09 '17 at 14:05
  • I get the following: `$ 09:04:40 miner ~ >> pip install --upgrade pyradigm Requirement already up-to-date: pyradigm in ./anaconda2/lib/python2.7/site-packages Requirement already up-to-date: numpy in Requirement already up-to-date: setuptools in Requirement already up-to-date: packaging>=16.8 in Requirement already up-to-date: appdirs>=1.4.0 in Requirement already up-to-date: six>=1.6.0 in Requirement already up-to-date: pyparsing in ` – Pradeep Reddy Raamana Mar 09 '17 at 14:08
  • Requirement already up-to-date: pyradigm in ./anaconda2/lib/python2.7/site-packages Requirement already up-to-date: for all of numpy setuptools packaging>=16.8 appdirs>=1.4.0 six>=1.6.0 pyparsing – Pradeep Reddy Raamana Mar 09 '17 at 14:12

1 Answers1

1

It's because you have a pyradigm module inside a pyradigm package.

I've installed the package in a virtualenv using pip install pyradigm and successfully imported MLDataset with

from pyradigm.pyradigm import MLDataset


If you want to import as

from pyradigm import MLDataset

update your __init__.py to

from pyradigm import MLDataset
Dušan Maďar
  • 9,269
  • 5
  • 49
  • 64