NOAA-ORR-ERD / OilLibrary

The NOAA library of oils and their properties.
Other
11 stars 17 forks source link

ImportError: cannot import name 'ZopeTransactionExtension' from 'zope.sqlalchemy' #31

Closed ctroupin closed 3 years ago

ctroupin commented 3 years ago

Hello,

I'm trying to install OilLibrary, here is what I've done (all in a virtualenv with python3.7):

git clone git@github.com:NOAA-ORR-ERD/OilLibrary.git
cd OilLibrary
pip install -r requirements.txt
python setup.py install

I use pip install in order to avoid mixing with conda (other packages were installed via pip), though I don't think that's the origin of the problem. The pip install went without errors.

python setup.py install gives this error:

running install
running bdist_egg
running egg_info
writing oil_library.egg-info/PKG-INFO
/home/ctroupin/Software/PythonEnvs/OpenDriftCanary/lib/python3.7/site-packages/setuptools/dist.py:127: UserWarning: newlines not allowed and will break in the future
  warnings.warn("newlines not allowed and will break in the future")
writing dependency_links to oil_library.egg-info/dependency_links.txt
writing entry points to oil_library.egg-info/entry_points.txt
writing top-level names to oil_library.egg-info/top_level.txt
reading manifest file 'oil_library.egg-info/SOURCES.txt'
writing manifest file 'oil_library.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
OilLibrary database generation failed
Traceback (most recent call last):
  File "setup.py", line 208, in <module>
    zip_safe=False,
  File "/home/ctroupin/Software/PythonEnvs/OpenDriftCanary/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/ctroupin/Software/PythonEnvs/OpenDriftCanary/lib/python3.7/site-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/home/ctroupin/Software/PythonEnvs/OpenDriftCanary/lib/python3.7/site-packages/setuptools/command/install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/ctroupin/Software/PythonEnvs/OpenDriftCanary/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 164, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "/home/ctroupin/Software/PythonEnvs/OpenDriftCanary/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 150, in call_command
    self.run_command(cmdname)
  File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/ctroupin/Software/PythonEnvs/OpenDriftCanary/lib/python3.7/site-packages/setuptools/command/install_lib.py", line 11, in run
    self.build()
  File "/usr/local/lib/python3.7/distutils/command/install_lib.py", line 105, in build
    self.run_command('build_py')
  File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 160, in run
    init_db()
  File "setup.py", line 88, in init_db
    import oil_library.initializedb
  File "/home/ctroupin/Software/OilLibrary/oil_library/__init__.py", line 16, in <module>
    from .models import DBSession
  File "/home/ctroupin/Software/OilLibrary/oil_library/models.py", line 26, in <module>
    from zope.sqlalchemy import ZopeTransactionExtension
ImportError: cannot import name 'ZopeTransactionExtension' from 'zope.sqlalchemy' (/home/ctroupin/Software/PythonEnvs/OpenDriftCanary/lib/python3.7/site-packages/zope/sqlalchemy/__init__.py

I see here that:

To make things clearer we renamed the ZopeTransactionExtension class to ZopeTransactionEvents. so I though that might be the reason.

What I've tried

  1. I've tried changing:

    from zope.sqlalchemy import ZopeTransactionExtension

    into

    from zope.sqlalchemy import ZopeTransactionEvents as ZopeTransactionExtension

    but that lead to other issues.

  2. Also tried to force the installation of zope.sqlalchemy==1.1 to use a version that still has the ZopeTransactionExtension, but also other errors came.

ChrisBarker-NOAA commented 3 years ago

This may be a sqlalchemy version issue.

I'm sorry that we have not maintained the requirements.txt file for pip. But see: #30 -- that may be the issue.

Take a look at the conda_requirements file in the develop branch for finer grained version specs.

We've also been testing with Python 3.8, which probably doesn't matter, but you never know.

A PR for a working requirements.txt file would be great.

ctroupin commented 3 years ago

Thanks, I'll check that, makes sense. Also OK to switch back to python3.8 (initially started with 3.8, then tried 3.7), even if it's minor.

ChrisBarker-NOAA commented 3 years ago

BTW: we are freezing development on tthe OIlLibrary in favor of:

https://github.com/NOAA-ORR-ERD/adios_oil_database

Which is not quite ready for integration with GNOME, but will be the way of the future.

-CHB

ctroupin commented 3 years ago

OK, so here is the requirements.txt I use to make it work:

numpy>=1.16.*
scipy>=0.18.1
SQLAlchemy<1.4
zope.sqlalchemy<=1.1
awesome-slugify>=1.6.5
pytest>=2.9.2
backports.functools_lru_cache>=1.5
pytest
gitpython
backports.functools_lru_cache
https://github.com/NOAA-ORR-ERD/PyNUCOS/archive/v2.5.5.tar.gz
future

I set SQLAlchemy<1.4 following #30 and zope.sqlalchemy<=1.1 to ensure ZopeTransactionExtension is still there. Probably you can close this issue, and I can PR this new requirements.txt.

ChrisBarker-NOAA commented 3 years ago

A PR would be great, thanks!