Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Default install of yamlreader from pip causes ImportError ( __main) #9

Closed
michael-dev2rights opened this issue Jan 12, 2017 · 8 comments

Comments

@michael-dev2rights
Copy link

If I try installing yamlreader on my Ubuntu system into a virtualenv it fails to work properly with an install. I get the error

Traceback (most recent call last):
  File "/tmp/test-yamlreader/bin/yamlreader", line 7, in <module>
    from yamlreader import __main
ImportError: cannot import name __main

I'd expect a default install to work fine.

NAME="Ubuntu"
VERSION="16.04.1 LTS (Xenial Xerus)"

Here's a log from the install.

mikedd@carla /tmp> virtualenv test-yamlreader
Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/test-yamlreader/bin/python2
Also creating executable in /tmp/test-yamlreader/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
(test-yamlreader) mikedd@carla /tmp> pip install yamlreader
]Collecting yamlreader
Collecting PyYAML (from yamlreader)
Collecting six (from yamlreader)
  Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: PyYAML, six, yamlreader
Successfully installed PyYAML-3.12 six-1.10.0 yamlreader-3.0.2
(test-yamlreader) mikedd@carla /tmp> yamlreader 
Traceback (most recent call last):
  File "/tmp/test-yamlreader/bin/yamlreader", line 7, in <module>
    from yamlreader import __main
ImportError: cannot import name __main
@michael-dev2rights
Copy link
Author

(test-yamlreader) mikedd@carla /tmp> python --version
Python 2.7.12

@mriehl
Copy link
Contributor

mriehl commented Jan 12, 2017

Your install is not broken. The import stanza is not right, which is your problem.

When you do

from yamlreader import ...

you hit the __init__.py in the yamlreader module (the folder in src/main/python in this git repository).
This file doesn't have a __main. It imports data_merge, yaml_load, YamlReaderError from yamlreader.py (using from .yamlreader import ...) though so you could import these symbols.

If you want something from the module (yamlreader.py as opposed to the package, yamlreader with an __init__.py) you need to import from the module, not from the package.

e.G. from yamlreader.yamlreader import __main

Does that make sense? Python's import syntax can be confusing and here it doesn't help that the module has the same name as the package.
If the package was named lib you'd do from lib.yamlreader import __main which is clearer I guess.

@mriehl
Copy link
Contributor

mriehl commented Jan 13, 2017

I'm closing this since

from yamlreader.yamlreader import __main

solves the issue. If you need more help or this didn't fix your problem, feel free to reopen!

@mriehl mriehl closed this as completed Jan 13, 2017
@michael-dev2rights
Copy link
Author

This isn't my code. It's the yamlreader command line tool.

@michael-dev2rights
Copy link
Author

Unfortunately I can't reopen this issue. You need to be a repository collaborator to do that. @mriehl could you please reopen the ticket.

@mriehl
Copy link
Contributor

mriehl commented Jan 18, 2017 via email

@mriehl mriehl reopened this Jan 18, 2017
@mriehl mriehl closed this as completed in 99daeef Jan 18, 2017
@mriehl
Copy link
Contributor

mriehl commented Jan 18, 2017

I've fixed it. But I don't have permissions to release on PyPI. @snordhausen could you do a release or setup travis upload?

@mriehl mriehl reopened this Jan 18, 2017
@snordhausen
Copy link
Contributor

The fixed version is now on Pypi (I bumped the version number, this made our internal build pass).

mriehl added a commit that referenced this issue Jan 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants