tensorflow / quantum

An open-source Python framework for hybrid quantum-classical machine learning.
https://www.tensorflow.org/quantum
Apache License 2.0
1.81k stars 580 forks source link

ImportError: cannot import name '_Task' from 'pp' #706

Open QuantumFall opened 2 years ago

QuantumFall commented 2 years ago

Hi all,

I am getting the error message above when trying to do import tensorflow_quantum as tfq and I'm not really sure how to resolve it.

The full error message is:

ImportError: cannot import name '_Task' from 'pp' (C:\Users\MyUsername\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\pp__init__.py)

I currently have TF and TFQ installed in a conda virtual environment with Python 3.7.13. TF and TFQ were installed using Pip according to these instructions: https://github.com/tensorflow/quantum/blob/master/docs/install.md

I'm not sure if it's related but doing "conda list" shows tensorflow as version 2.4.1 but doing the following in jupyter notebook returns 2.7.0.

import tensorflow as tf
tf.__version__

Any help would be appreciated!

lockwo commented 2 years ago

I've had problems before with version control before, my usual recommendation is to create a fresh python environment and install everything anew (seems to have worked for other problems in the past: https://github.com/tensorflow/quantum/issues/602). I cannot say I have ever heard of you specific problem before, but it might be some version problem that could be fixed with a new environment.

QuantumFall commented 2 years ago

Thanks for the suggestion!

I have deleted the conda environment and created a new one. This time using Python 3.8.13. Following the install commands in the link above again, I have verified that I am on Tensorflow 2.7.0. However, trying to run pip3 install -U tensorflow-quantum returns the following error:

ERROR: Could not find a version that satisfies the requirement tensorflow-quantum (from versions: none)
ERROR: No matching distribution found for tensorflow-quantum

From searching online, this issue is usually encountered when someone tries to install the package into 32bit Python. However, I have verified that my Python is 64bit.

I've found this stackoverflow post and it seems like TFQ doesn't play well with Windows?

https://stackoverflow.com/questions/64892612/tensorflow-quantum-requires-manylinux2010-is-there-a-workaround-to-get-tensorfl

EDIT: Just saw from #673 and #671 that TFQ 0.3 is the last version that supports windows and probably why it can't be installed using Pip.

lockwo commented 2 years ago

Yea, TFQ hasn't supported windows since 0.3. I recommend either using WSL, Colab, or some cloud compute resources.

lockwo commented 2 years ago

Any updates on this or should it be closed?

mhucka commented 1 day ago

@QuantumFall This issue has not been active for a long time. Did you eventually resolve it? Can this issue report be closed?