ModuleNotFoundError: No module named 'tensorflow_quantum' - python

I'm using Python 3.8(64-bit)
Basically, I tried every possible solution on the internet like update the python version and tensorflow version etc.
But when I try to do this:
import tensorflow_quantum as tfq
terminal always say:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow_quantum'
Does anyone have any idea on this issue? Cheers

Please run the following:
pip3 install --upgrade pip
pip3 install tensorflow==2.3.1
pip3 install -U tensorflow-quantum

I have faced quite a similar problem and I followed this link for some help
in short I created a virtual environment with
python version == 3.6.2
conda create -n your_new_env_name python=3.6.2 anaconda
and then activated this environment as follows before you continue
conda activate your_new_env_name
then installed tensorflow
pip install tensorflow==2.1.0
pip install tensorflow-gpu=2.0.0
pip install tensorflow-quantum
you may face 2 errors which you might need to be solved
the first is this
When importing tensorflow, I get the following error:
No module named 'numpy.core._multiarray_umath'
all you have to do is this
pip install numpy --upgrade
or if needed
pip install numpy --upgrade --user
you may also get an error when import tensorflow-quantum that's related to google.api_core and what solved the problem for me was to do the following
pip install google.api_core==1.16.0
you may also need to the following
pip install cython
I hope it works!

Related

System PIP seems broken after I tried to upgrade it on my Big Sur / Apple silicon Macbook

It seems like I messed up the system pip by pip3 install --upgrade pip. Actually I even do not exactly remember whether I did upgrade or not.
Now when I try to use pip3, it gives an error like
Traceback (most recent call last):
File "/Applications/Xcode.app/Contents/Developer/usr/bin/pip3", line 6, in <module>
from pip._internal import main
ImportError: cannot import name 'main' from 'pip._internal' (unknown location)
I tried sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall to revert back PIP by this answer, but it fails.
/Applications/Xcode.app/Contents/Developer/usr/bin/python3: No module named pip.__main__; 'pip' is a package and cannot be directly executed
which pip3 gives /usr/bin/pip3
Now I am trying to revert back the system tools and use virtual environment.
What should I do? I can't even check which pip version is installed at the moment.
Thanks in advance.

ImportError: No module named torch

I'm trying to install this framework from Github called torch2trt (found here:https://github.com/NVIDIA-AI-IOT/torch2trt).
I ran the following code in a Python terminal to install it:
git clone https://github.com/NVIDIA-AI-IOT/torch2trt
cd torch2trt
python setup.py install
but ended up with the following error message:
Traceback (most recent call last):
File "setup.py", line 2, in <module>
import torch
ImportError: No module named torch
I have already installed pytorch using pip install torch torchvision
Does anyone know how to resolve this?
Try running everything in python3:
python3 -m pip install torch torchvision
followed by :
python3 setup.py install
In Linux,
which python
which pip
In Windows power shell
where python
where pip
Check if both pip and python are from same parent directory.
python defaults to python2
So you should change python setup.py install to python3 setup.py install
Otherwise you can check the PyTorch page and try another version. https://pytorch.org/get-started/locally/
I would try this one first.
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
You haven't installed Torch. Install it with pip via: https://pytorch.org/get-started/locally/

Why can't I use pip3 after installing pip?

I want to install tensorflow-cpu using pip on my Ubuntu 18.04, 64-bit system and it required pip>=19.0.
I was having pip 9.0.x and was using pip3 to install packages but to fulfill the requirement I ran
pip3 install pip
which installed pip 19.2.3 but after doing it I can no longer use pip3. Using pip3 now gives this error
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'
Earlier using pip would give this error
Command 'pip' not found, but can be installed with:
sudo apt install python-pip
but now using it to install packages works totally fine.
I read a lot of articles after which I realised that we use pip for python 2.x and for python 3.x we use pip3. But with the change in behaviour after upgrading pip I'm totally confused and can't find any help. Is using pip to install a package same as installing it using pip3. What are the differences between them?

Import pandas error

I keep getting an error in Git Bash as I run my python code:
$ python Humiditypyth.py
Traceback (most recent call last):
File "Humiditypyth.py", line 1, in <module>
import pandas as pd
ImportError: No module named pandas
I have Anaconda installed and I checked in "python list" that pandas is installed. Can you please help?
Try
python3.6 Humiditypyth.py. [try using sudo if it doesn’t help]
pip3 freeze - check if you can see pandas in there. If not do
pip3 install pandas
Let's do a checklist
Do you have anaconda installed in the same python version that you are using? e.g. if python is calling python2.7 and python3 does python 3.6 you have to install anaconda in the right folder with either "sudo pip install anaconda" or "sudo pip3 install anaconda"
after that I think you still have to install pandas "pip install pandas" or "pip3 install pandas"
I might be wrong though I never used that library.

No module named packaging

I work on Ubuntu 14. I install python3 and pip3.
When I try to use pip3, I have this error
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 70, i
n <module>
import packaging.version
ImportError: No module named 'packaging'
Does someone know what is the issue?
Many thanks
First update your pip version itself. You can take a look at this answer
pip3 install --upgrade pip
And then try to install packaging, if its not already installed by now.
pip3 install packaging
I recently had the same error. Unfortunately none of the other answers solved my problem. Finally installing the following package resolved my issue:
sudo apt install python3-packaging
For older versions of Python you may need to adjust the command:
sudo apt install python-packaging
If I understand well, the issue that causes confusion in other's replies is that you have an error while running pip itself, which prevents self-updates of pip or installation of the missing package.
As requested, please state exactly how you installed Python 3 and pip. Ubuntu 14 does not come with Python 3.5.
For diagnosis, please give the output of
which python3
that is probably /usr/bin/python3 and refers to the system-wide python3 while your pip is located in /usr/local/bin/pip3.
Suggested solution: Uninstall system pip with apt-get remove python3-pip and try again with either pip3 or python3.5 -m pip.
I got this issue and I solved it by getting the path to my python module on my virtualenv
python3.7 -c 'import sys; print(sys.path)'
Then I cloned github repository for Packaging
in one of the directory..
That's about it
I tried all of the above.
I had to manually add the libraries to the pyinstaller command as data:
.\pyinstaller.exe -F --add-data ".\venv\Lib\site-packages\packaging;packaging" --add-data ".\venv\Lib\site-packages\webdriver_manager;webdriver_manager" --onefile .\departed_shipments.py

Categories