fusionbox / django-pyscss

Makes it easier to use PyScss in Django
https://pypi.python.org/pypi/django-pyscss
BSD 2-Clause "Simplified" License
19 stars 13 forks source link

ImportError: No module named pathlib #33

Closed fungi closed 9 years ago

fungi commented 9 years ago

New in 2.0.0: import Py3K stdlib module pathlib even on Python 2.x where it does not exist

Traceback (most recent call last):
  File "/opt/stack/new/horizon/manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 87, in create
    module = import_module(entry)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/django_pyscss/__init__.py", line 1, in <module>
    from .compiler import DjangoScssCompiler  # NOQA
  File "/usr/local/lib/python2.7/dist-packages/django_pyscss/compiler.py", line 4, in <module>
    from pathlib import PurePath
ImportError: No module named pathlib
cboylan commented 9 years ago

Note pathlib is not in stdlib for python < 3.4. You can install it from pypi but django-pyscss does not list pathlib as a dependency in its setup.py so it does not get installed on older python.

gavinwahl commented 9 years ago

Thanks for the report guys. Patch incoming.

rockymeza commented 9 years ago

Hi,

Thanks for bringing this up. Can I ask what version of pyScss you are using? I'm liking at their choice and it seems to depend on pathlib for Python < 3.4. We're running the tests on Python 3.3 and 3.4 and it seems to be working.

Thanks again! -Rocky Meza 2015年4月22日 下午6:10于 "Clark Boylan" notifications@github.com写道:

Note pathlib is not in stdlib for python < 3.4. You can install it from pypi but django-pyscss does not list pathlib as a dependency in its setup.py so it does not get installed on older python.

— Reply to this email directly or view it on GitHub https://github.com/fusionbox/django-pyscss/issues/33#issuecomment-95372506 .

gavinwahl commented 9 years ago

That is pretty strange since pyScss 1.3 has pathlib as a dependency. How did you install django-pyscss?

django-pyscss should probably have it as a dependency no matter what since it does import it.

gavinwahl commented 9 years ago

I think I see what's going on. You guys are requiring pyScss<1.3: https://github.com/openstack/requirements/blob/8c0ff9178c367c5749100fdf00e3a61815c81baa/global-requirements.txt#L48. django-pyscss 2.0 requires pyScss>=1.3. (See the changelog for 2.0.0: https://pypi.python.org/pypi/django-pyscss/2.0.0#id1). You should stay on the 1.x series of django-pyscss if you really need pyScss 1.2, or allow pyScss 1.3 in your requirements.

I can explicitly require pathlib and release 2.0.1 if it will help at all, but you're still going to have to change your pin. I'm going to close this since pathlib does get installed with the right version of pyScss, but feel free to comment if you want 2.0.1.

greghaynes commented 9 years ago

Good find, I believe you are correct about our requirements mismatch.

From what I can tell the backtrace originates from django-pyscss calling into pathlib directly so I do think adding a dependency on pathlib is something that should happen in django-pyscss, reguardless.

Thanks!

fungi commented 9 years ago

Agreed. If django-pyscss imports a module then it should ideally have the package providing that module listed as a direct dependency, not simply rely on it being provided as a transitive dependency (this is an insurance policy against a future update to pyScss dropping its use of pathlib).

It's still odd that the versioned install_requires on pyScss>=1.3.4 didn't raise an error during installation.

Anyway, thanks for spotting the mismatch! I'll get our requirements adjusted to accomodate that.

rockymeza commented 9 years ago

Fixed in the 2.0.1 release! Thanks for bringing this up!

https://pypi.python.org/pypi/django-pyscss/2.0.1