Unable to import mlflow, getting ModuleNotFoundError: No module named 'mlflow' - python-3.x

Unable to import mlflow in a .py script.
ModuleNotFoundError: No module named 'mlflow'
The script runs in a python:3.7-stretch Docker container
Use requirements.txt to pip install packages.
(...)
sqlalchemy==1.4.1
psycopg2==2.8.6
mlflow==1.18.0
RUN pip3 install --default-timeout=5000 --use-deprecated=legacy-resolver -r /root/requirements.txt
Can see that it is installed.
root#abc:~# pip uninstall mlflow
Found existing installation: mlflow 1.18.0
Uninstalling mlflow-1.18.0:
Would remove:
/usr/local/bin/mlflow
/usr/local/lib/python3.7/site-packages/mlflow-1.18.0.dist-info/*
/usr/local/lib/python3.7/site-packages/mlflow/*
Proceed (y/n)? n
Can do an import from python shell.
root#abc:~# python
Python 3.7.10 (default, Feb 16 2021, 19:46:13)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import mlflow
>>>
But no joy when running from .py script.
Other packages installed from requirements.txt can be imported.
Any ideas what is wrong ?

Related

How to install pip3 for a specific python version

I have python3.7 installed but also python3.4. For example:
$ python3
Python 3.4.3 (default, Nov 12 2018, 22:25:49)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
And:
$ python3.7
Python 3.7.0 (default, Jun 28 2018, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
How can I install packages to python3.7 ? Any pip3 command I use goes to python3.4 and I'm not sure how to install anything for python3.7. Any ideas? Even running something like this doesn't work:
$ python3.7 -m ensurepip --upgrade
/usr/bin/python3.7: No module named ensurepip
Or:
$ sudo python3.7 -m pip install PyMySQL
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I don't know whether this may be an appropriate solution for you. But this is what I generally follow.
Just install Anaconda in your system and create different environments according to your needs.
For your case create two different environments one for Python 3.4.3 and another for Python 3.7 using the following command
conda create --name py34 python=3.4.3 and
conda create --name py37 python=3.7
//This lines will create two new environments named py34 and py37
You then install libraries according to your needs in the respective environment. Now you can work into each environment without interfering with the libraries of the other environment.
To use anaconda kindly follow Anaconda cheatsheet. You will get everything that you need.
Hope this will help you.
This might help : It addresses the same issue as yours. In short, try
python3.7 -m pip install pip
Here's a reference documentation

How to import PyQt4 onto pycharm

I'm trying to import PyQt4 onto pycharm on Ubuntu
I successfully installed PyQt4 by using sudo apt-get install python-qt4, and I can import PyQt4 on terminal:
~$ python
Python 2.7.15+ (default, Nov 27 2018, 23:36:35)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> quit()
But i just can't import PyQt4 onto Pycharm. I tried to add it onto the interpreter Paths, but when I run the code, it still shows no module named PyQt4
by this command sudo apt-get install python-qt4 you download for python2 but actuly pycharm uses python3 so you should run this command : sudo apt install python3-pyqt4

python3.6 help command dumping core when we try help(tensorflow)

I am running Ubuntu Linux 18.04 on Virtual box,
I have installed tensorflow properly in venv and import works fine and also
I could run some sample programs with tensorflow, but when i try help(tf) python prompt as show below in the logs, I am hitting coredump,
`(venv) shiv#shiv-vbox:~/TF$ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> x=0
>>> help(x)
>>> help(tf)
Segmentation fault (core dumped)`
Is something wrong with my installation? i tried multiple times to install to confirm some issue with install but all the time I am getting cordump when I do help(tf), any inputs on this would be helpful.
-Thank you
update
I followed following steps to install
shiv#shiv-vbox:~/TF$ sudo virtualenv --system-site-packages -p python3 ./venv
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/shiv/TF/venv/bin/python3
Also creating executable in /home/shiv/TF/venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
shiv#shiv-vbox:~/TF$ source ./venv/bin/activate
(venv) shiv#shiv-vbox:~/TF$
(venv) shiv#shiv-vbox:~/TF$ ls
Tflow venv
(venv) shiv#shiv-vbox:~/TF$ pip install --upgrade pip
Requirement already up-to-date: pip in ./venv/lib/python3.6/site-packages (18.1)
(venv) shiv#shiv-vbox:~/TF$ pip install tensorflow

ModuleNotFoundError: No module named 'JayDeBeApi3'

I don't understand why Python3 is giving me an module not find error on importing JayDeBeApi3 module.
import JayDeBeApi3
ModuleNotFoundError: No module named 'JayDeBeApi3'
Please below, JayDeBeApi3 is successfully installed
pip3 install JayDeBeApi3
Collecting JayDeBeApi3
Using cached JayDeBeApi3-1.3.2.tar.gz
Requirement already satisfied: py4j in /usr/local/lib/python3.6/site-packages (from JayDeBeApi3)
Installing collected packages: JayDeBeApi3
Running setup.py install for JayDeBeApi3 ... done
Successfully installed JayDeBeApi3-1.3.2
BELOW IS PYTHONPATH SETTING
Python 3.6.0 (default, Nov 27 2017, 11:04:30)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import sys
print (sys.path)
['', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/root/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/site-packages']
# locate JayDeBeApi3
usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/PKG-INFO
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/SOURCES.txt
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/dependency_links.txt
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/installed-files.txt
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/requires.txt
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/top_level.txt
Downloading JayDeBeApi3 1.3 from https://pypi.python.org/pypi/JayDeBeApi3/1.3 and installing it locally resolved the issue for me. Though, I am sure, that's not an actual solution.

Can't import paramiko in Python 3/Ubuntu

I installed the paramiko lib with Ubuntu's APT repositories (sudo apt-get install python3-paramiko), and I can't import it :
$ python3
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'paramiko'
But when I install it with pip3 install paramiko, the import paramiko line works !
I could just stick with the pip version, but I want to distribute this program, and it would be very convenient to give all the dependencies as APT packages.
Why can Python import the pip version, but not the APT one ?
Maybe the apt package is installed to a dir not recognized by python3, that is, not in one of sys.path. compare the installed dir of python3-paramiko and the output of python3 -c 'import sys;print(sys.path)'.
Also, it's good practice for your python package to depend on packages installed by pip. Since you could distribute your package via setuptools and configure your dependency therein. Which make your program cross platform.

Resources