Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError when installing from source code #52

Closed
alembcke opened this issue Jun 17, 2021 · 3 comments
Closed

ImportError when installing from source code #52

alembcke opened this issue Jun 17, 2021 · 3 comments

Comments

@alembcke
Copy link
Contributor

I installed tf-quant-finance from source cloned on 16-Jun-2021 and get the below error:

>>> import tf_quant_finance as tff
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tf-quant-finance/tf_quant_finance/__init__.py", line 74, in <module>
    from tf_quant_finance import experimental
  File "/tf-quant-finance/tf_quant_finance/experimental/__init__.py", line 19, in <module>
    from tf_quant_finance.experimental import local_stochastic_volatility
  File "/tf-quant-finance/tf_quant_finance/experimental/local_stochastic_volatility/__init__.py", line 17, in <module>
    from tf_quant_finance.experimental.local_stochastic_volatility.local_stochastic_volatility_model import LocalStochasticVolatilityModel
  File "/tf-quant-finance/tf_quant_finance/experimental/local_stochastic_volatility/local_stochastic_volatility_model.py", line 25, in <module>
    from tf_quant_finance.experimental import local_volatility as lvm
  File "/tf-quant-finance/tf_quant_finance/experimental/local_volatility/__init__.py", line 18, in <module>
    from tf_quant_finance.experimental.local_volatility.local_volatility_model import LocalVolatilityModel
  File "/tf-quant-finance/tf_quant_finance/experimental/local_volatility/local_volatility_model.py", line 25, in <module>
    from tf_quant_finance.experimental.pricing_platform.framework.market_data import volatility_surface
  File "/tf-quant-finance/tf_quant_finance/experimental/pricing_platform/__init__.py", line 17, in <module>
    from tf_quant_finance.experimental.pricing_platform import framework
  File "/tf-quant-finance/tf_quant_finance/experimental/pricing_platform/framework/__init__.py", line 17, in <module>
    from tf_quant_finance.experimental.pricing_platform.framework import core
  File "/tf-quant-finance/tf_quant_finance/experimental/pricing_platform/framework/core/__init__.py", line 17, in <module>
    from tf_quant_finance.experimental.pricing_platform.framework.core import business_days
  File "/tf-quant-finance/tf_quant_finance/experimental/pricing_platform/framework/core/business_days.py", line 18, in <module>
    from tf_quant_finance.experimental.pricing_platform.instrument_protos import business_days_pb2
  File "/tf-quant-finance/tf_quant_finance/experimental/pricing_platform/instrument_protos/__init__.py", line 17, in <module>
    from tf_quant_finance.experimental.pricing_platform.instrument_protos import all_instruments_pb2 as instruments
ImportError: cannot import name 'all_instruments_pb2' from partially initialized module 'tf_quant_finance.experimental.pricing_platform.instrument_protos' (most likely due to a circular import)

This looks to be a bug which was introduced recently (last time I installed from source on 18-May-2021 I did not get this error).

I am not familiar with any of the files mentioned here, so would not be the best person to investigate. Is there someone who can investigate this? Do others get the same error when installing from source?

@cyrilchim
Copy link
Contributor

Thanks for reporting. Let me try to reproduce

@cyrilchim
Copy link
Contributor

I think I can reproduce the issue. Following the instructions, I assume you have run ./bazel-bin/build_pip_pkg artifacts followed by pip install --user --upgrade artifacts/*.whl. If I run python3 and try to import tf_quant_finance, the reported error indeed appears.

The issue here is that you are still in /tf-quant-finance folder. Please move out of the folder cd .. and try importing the library from there.

Please let me know if this helps.

@alembcke
Copy link
Contributor Author

That fixed it, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants