tensorflow module not found, while using streamlit - python

PS D:\projects\fashion-recommender-system> streamlit run main1.py
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://192.168.1.213:8501
2022-05-04 14:12:41.903 Traceback (most recent call last):
File "C:\Users\prana\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\streamlit\scriptrunner\script_runner.py", line 443, in run_script
exec(code, module.dict)
File "D:\projects\fashion-recommender-system\main1.py", line 1, in
import tensorflow
File "C:\Users\prana\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tensorflow_init.py", line 37, in
from tensorflow.python.tools import module_util as _module_util
ModuleNotFoundError: No module named 'tensorflow.python'
above is the output of terminal.
tensorflow is installed in python and does work when I run python file, but when I run the python file using streamlit run main.py, It doesn't find any tensorflow module.
I have installed python versions of 3.9 and 3.7
In 3.7 python shell when I import tensorflow, there is no error
In 3.9 python shell when I import tensorflow there is error
when I run pip --version command it gives me this warning
pip --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 22.0.4 from C:\Users\prana\AppData\Roaming\Python\Python37\site-packages\pip (python 3.7)
I don't know what is causing streamlit to not found tensorflow module, please help me.

Related

Unable to import python modules from a python file in google collab

!python3.6 abc.py
I am trying to execute the above line of code in google collab.
abc.py contains modules imported like NumPy, sklearn. Recently, I am getting this error in collab :
Traceback (most recent call last):
File "abc.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
This error had never occurred on my previous usages of this code. Please help.
install the packages listed in your file using
pip install <package_name>
safe to install them in virtual environment.
Make sure you have activated virtual environment if you are using one already.
you can use conda install numpy

Can't run Jupiter Notebook on Mac m1

Just reinstalled Anaconda on my Mac m1, and now when I try and open Jupyter Notebook using the command line, it gives me this error:
jupyter notebook
Traceback (most recent call last):
File "/Users/alborzgharabaghi/opt/anaconda3/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/Users/alborzgharabaghi/opt/anaconda3/lib/python3.8/site-packages/notebook/notebookapp.py", line 49, in <module>
from zmq.eventloop import ioloop
File "/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/__init__.py", line 57, in <module>
_load_libzmq()
File "/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/__init__.py", line 32, in _load_libzmq
from . import libzmq
ImportError: dlopen(/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/libzmq.cpython-38-darwin.so, 10): no suitable image found. Did find:
/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/libzmq.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/alborzgharabaghi/.local/lib/python3.8/site-packages/zmq/libzmq.cpython-38-darwin.so: mach-o, but wrong architecture
Any help would be appreciated.
The problem is coming from the pyzmq library!
Its non-M1 compatible version has probably been installed on your Mac.
You will need to reinstall it with a Rosetta Terminal.
Step 1: create a new Rosetta terminal, follow that tuto (or any other on the web)
Step 2: open your new Rosetta terminal and re-install pyzmq:
pip uninstall pyzmq
pip install pyzmq
I've been experiencing similar issues with this and other CLI commands with the M1. MacOS ships with an old version of Bash, updating Bash to v5 (and making sure I'm running commands in that environment) cleared up this error for me. This article helped: Upgrading Bash on MacOS

Openvino with python is returning some error

I'm trying to run this application using openvino, but I'm getting the following error:
/usr/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.7 of module 'openvino.inference_engine.ie_api' does not match runtime version 3.6
return f(*args, **kwds)
But when I ran the application using python 3.7, I've got this error:
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "./face_recognition_demo.py", line 24, in
import cv2
ImportError: numpy.core.multiarray failed to import
Does anyone knows how to fix this?
Looks like that some packages in your environment are incompatible. To fix this I recommend to run the sample using virtual environment. Please follow:
python3 -m venv ./virtual-env
source ./virtual-env/bin/activate
pip3 install -r requirements.txt
Then try to run the sample again.

Tensorflow installation error: No module named _pywarp_tensorflow

I installed tensorflow using this link on StackOverflow.
But, when I tried to run my code, I got the error below
This is my system's information
(env) PS C:\SD\project> python --version
Python 3.7.3
(env) PS C:\SD\AnomalyDetectionCVPR2018> pip3 --version
pip 19.1.1 from c:\sd\env\lib\site-packages\pip (python 3.7)
The error that I got:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\SD\env\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\SD\env\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\SD\env\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
What am I doing wrong? So far I've used Python and pip with no issues.
again, I had the same problems that you have now, I tryed install tensorflow in windows7, windows 8 and 10 inclusive in virtual machinnes, the same problem was for matplotlib.
My solution was remove my python version and I installed Anaconda,
Try to install Anaconda3-4.4.0-Windows-x86_64 or Anaconda3-4.4.0-Linux-x86_64.sh for linux, this version was released in 2017-05-26.
Anacoda versions
And then try to install tensorflow, matplotlib, pandas, numpy but before run
conda update conda
To update some packages of anaconda. And you will install those the packages/libraries without problems,
Best Regards

'ImportError: cannot import name cbook' when using PyCharm's Profiler

I am trying to run the PyCharm profiler but I get the following error message:
Traceback (most recent call last):
File "/home/b3053674/ProgramFiles/pycharm-2017.1.4/helpers/profiler/run_profiler.py", line 164, in <module>
profiler.run(file)
File "/home/b3053674/ProgramFiles/pycharm-2017.1.4/helpers/profiler/run_profiler.py", line 89, in run
execfile(file, globals, globals) # execute the script
File "/home/b3053674/Documents/pycotools/pycotools/tasks.py", line 38, in <module>
import viz,errors, misc, _base, model
File "/home/b3053674/Documents/pycotools/pycotools/viz.py", line 53, in <module>
import matplotlib.pyplot as plt
File "/home/b3053674/anaconda2/envs/pycotools/lib/python2.7/site-packages/matplotlib/__init__.py", line 124, in <module>
from . import cbook
ImportError: cannot import name cbook
Snapshot saved to /home/b3053674/.PyCharm2017.1/system/snapshots/pycotools30.pstat
Process finished with exit code 1
I am using a conda environment which I have switched to in the terminal:
$ source activate <env>
then updated matplotlib
$pip install matplotlib --upgrade
and six just for good measure
$pip install six --upgrade
(note that I've also manually deleted these packages from site-directory of my environment and reinstalled just incase --upgrade wasn't behaving)
I've looked here and here and neither solutions solved my problem.
I've also switched the PyCharm Run configurations to use each of my conda environments in turn all of which produce the same error.
Note that the profiler has worked before in the past and the code works fine when I use the normal way of executing the code. Does anybody have any idea of what is going on?
Thanks
I encountered the same error today, although probably for a different reason - the packages for matplotlib and/or six appear to be broken.
Resolved it by downgrading to the previous versions:
conda install six=1.10.0
conda install matplotlib=2.0.2
I had the same issue.
Downgrading to matplotlib 2.0.2 seems to fix it.
pip uninstall matplotlib
pip install matplotlib==2.0.2
I had this error in jupyter but not IPython. Fixed with $ conda install matplotlib=2.0.2 as above but six not downgraded. Don't forget (as I did) to restart the kernel.

Categories

Resources