Splitframe
Splitframe

Reputation: 434

Ruamel yaml import does not work

I want to use Ruamel YAML in my project, I am behind a proxy so I downloaded

The gzip package from https://pypi.python.org/pypi/ruamel.yaml and installed it with
pip install ruamel.yaml-0.15.19.tar.gz.

I use LiClipse on Windows 10 and I see the ruamel package inside my project explorer under lib/site-packages/ruamel, but I cannot import and use it.

It cannot resolve the import.

Other frameworks like paho MQTT or pySerial worked without problems.

Output of pip list --format-columns

Package     Version
----------- -------
paho-mqtt   1.1
pip         9.0.1
pyserial    3.3
ruamel.yaml 0.15.19
setuptools  28.8.0

enter image description here

Upvotes: 1

Views: 2051

Answers (1)

Anthon
Anthon

Reputation: 76599

I have looked through the source of PyDev 5.8.0 ( LiClipse seem closed source, but the pydev stuff—that I assume handles all the Python related stuff—is open source).

In there, there is in pydevd.py has module get_fullname() and that correctly finds ruamel.yaml if installed:

Python 3.6.2 (default, Jul 17 2017, 14:33:45) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkgutil
>>> loader = pkgutil.get_loader('ruamel.yaml')
>>> def get_fullname(self, mod_name):
...     if IS_PY3K:
...         import pkgutil
...     else:
...         from _pydev_imps import _pydev_pkgutil_old as pkgutil
...     try:
...         loader = pkgutil.get_loader(mod_name)
...     except:
...         return None
...     if loader is not None:
...         for attr in ("get_filename", "_get_filename"):
...             meth = getattr(loader, attr, None)
...             if meth is not None:
...                 return meth(mod_name)
...     return None
... 
>>> IS_PY3K=True
>>> get_fullname(None, 'ruamel.yaml')
'/home/venv/tmp-d2e4bd3600c863b7/lib/python3.6/site-packages/ruamel/yaml/__init__.py'

(since self is not referenced this should probably be removed and decorated @staticmethod).

I searched the sources for Unresolved import and Unused import to see if there is some other similar functionality, but could not directly find anything. Since the import will work, even when this message shows, it does however look like there is some other (incompatible) way LiClipse uses to look for imports as well.

ruamel.yaml is a namespace based package (i.e. there are 200+ other packages that start with ruamel., some of which are on PyPI as well) and this can cause problems. That is also the reason why you have to use pip to install.

I have sent a issue report per email to Fabio Zadrozny (the author) about this and offered my assistance to help look into this.

Upvotes: 2

Related Questions