How to import PyQt4 onto pycharm - pyqt

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

Related

Unable to import mlflow, getting ModuleNotFoundError: No module named 'mlflow'

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 ?

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

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

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.

Installing matplotlib for python3 on Ubuntu

I'm running Ubuntu 12.04, and I need to use matpltlib in Python 3.2.3. I successfully installed it using
sudo apt-get install python-matplotlib
But now it works only in Python 2.7, which seems to be the default version:
$ python2
Python 2.7.3 (default, Feb 27 2014, 20:00:17)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>
But python 3 doesn't work:
$ python3
Python 3.2.3 (default, Feb 27 2014, 21:33:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>>
Also, my python command seems to be 'broken':
$ python
bash: /usr/bin/python: No such file or directory
Any help is appreciated!
In case anyone else stumbles upon this, just use
sudo apt-get install python3-matplotlib
There are many packages involved with matplotlib and using apt-get instead of pip this is the officially recommended approach.
if you are in virtualenv
example: workon cv #cv is my virtualenv name
$ workon cv
$ pip install matplotlib

Resources