No longer able to launch Spyder since updating PyQt5 via pip - python-3.x

Since updating my python3 packages via python3-pip on Ubuntu 18.04.2 LTS I am unable to launch spyder as it appears that the QtWebKitWidgets module of the PyQt5 package has been deprecated. The following console output is produced upon entering spyder3 in the terminal:
Traceback (most recent call last):
File "/home/benjamin/.local/lib/python3.6/site-packages/qtpy/QtWebEngineWidgets.py", line 22, in <module>
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/benjamin/.local/bin/spyder3", line 11, in <module>
sys.exit(main())
File "/home/benjamin/.local/lib/python3.6/site-packages/spyder/app/start.py", line 178, in main
from spyder.app import mainwindow
File "/home/benjamin/.local/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 90, in <module>
from qtpy import QtWebEngineWidgets # analysis:ignore
File "/home/benjamin/.local/lib/python3.6/site-packages/qtpy/QtWebEngineWidgets.py", line 26, in <module>
from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets'
Has anyone else stumbled across this problem, and could anyone suggest a solution?
I currently update my python3 packages via the following shell script:
#!/bin/sh
#================================#
# #
#### UPDATE PYTHON3 LIBRARIES ####
# #
#================================#
### Package List ###
# bs4 - web scraping
# keras - machine learning front end
# lifelines - survival analysis
# matplotlib - plots
# numpy - array-processing package
# pandas - data management
# scipy - open-source software for mathematics, science, and engineering
# seaborn - plots
# selenium - web scraping
# spyder - IDE
# statsmodels - basic statistical methods
# tensorflow - machine learning back end
PACKAGES='bs4 keras lifelines matplotlib numpy pandas scipy seaborn selenium spyder statsmodels tensorflow'
### Update via PIP3 ###
echo 'Updating packages ...'
pip3 install $PACKAGES --user --upgrade --upgrade-strategy="eager"
echo 'Update complete ...'
... and launch spyder using the following Gnome applications launcher link, located in ~/.local/share/applications:
[Desktop Entry]
Type=Application
Version=1.0
Name=Spyder3
GenericName=Spyder3
Comment=The Scientific Python Development Environment - Python 3
Icon=spyder3
TryExec=spyder3
Exec=spyder3 %F
Terminal=false
MimeType=text/x-python;
Categories=Development;Science;IDE;Qt;
Keywords=Development;Science;IDE;Qt;
StartupNotify=true
StartupWMClass=Spyder

(Spyder maintainer here) To fix this problem you also need to install pyqtwebengine (besides pyqt5), like this
pip install pyqtwebengine
Note: We realized WebEngine was separated from PyQt5 only after we released our last version (3.3.3). But that's going to be fixed in our next one (3.3.4), to be released in March/2019.

Related

64bit MacOs After succesfully installing Pygame: ModuleNotFoundError: No module named 'pygame'

Python noob here. I've been trying to install pygame and pandas for a few hours now. Even with Conda I did not succeed. I have Python 3.8.5 installed.
I eventually tried through the terminal with these commands:
python -m pip install pygame==2.0.0.dev6
and
python -m pip install pandas
(this was a total guess by the way, but apparently it did something)
Results were succesfull:
Requirement already satisfied: pygame==2.0.0.dev6 in /opt/miniconda3/lib/python3.8/site-packages (2.0.0.dev6)
and
Successfully installed numpy-1.19.2 pandas-1.1.2 python-dateutil-2.8.1 pytz-2020.1
But, when I try to import either modules, I still get errors. Any ideas?
import pygame
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
import pandas
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
Do I need to move the modules to the script folder or something? Or what do I even move? Thanks!
Ok.. Got it thanks to #matt.. after succesfully installing pygame, find the environment in which pygame is installed by entering 'which python'.
In my case it returned:
/opt/miniconda3/bin/python
Now I needed to make sure the VS console was pointing at the same environment, by checking which python interpreter it was using and selecting the correct one. More info:
how to check and change environment in VS Code

ImportError while importing sklearn

I am using python 3.7
Recently I started getting this error while importing sklearn module.
I get the same error in Jupyter Notebook, Python IDLE, Pycharm virtual environment
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\aditya\AppData\Roaming\Python\Python37\site-packages\sklearn\__init__.py", line 75, in <module>
from .utils._show_versions import show_versions
File "C:\Users\aditya\AppData\Roaming\Python\Python37\site-packages\sklearn\utils\_show_versions.py", line 12, in <module>
from ._openmp_helpers import _openmp_parallelism_enabled
ImportError: DLL load failed: The specified module could not be found.
I have tried reinstalling too.
After that I copied contents of sklearn of venv of another project which had no issues. This thing worked for couple of times. But now it's not working again
Note: pandas, numpy, scipy etc are installed and working absolutely fine. Sklearn was also working fine few days back
This is an issue in the packaging in scikit-learn 0.22.0 which will be solved in 0.22.1 (released next week). The issue is tracked at: github.com/scikit-learn/scikit-learn/issues/15899. There are 2 possible workarounds:
Install scikit-learn from conda-forge (conda include the missing dll) by default: conda install conda-forge::scikit-learn
Install VC++ which will have the openmp library (https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)

PyCharm and turtle

I have a problem with PyCharm. I start learning python with PyCharm and I want write some with turtle package. When i try execute this code
import turtle
bob = turtle.Turtle()
I have that message:
"C:\Program Files\Python36\python.exe" C:/Users/Ptr/Desktop/python/Proj_1/Gui.py
Traceback (most recent call last):
File "C:/Users/Ptr/Desktop/python/Proj_1/Gui.py", line 1, in <module>
import turtle
File "C:\Program Files\Python36\lib\turtle.py", line 107, in <module>
import tkinter as TK
File "C:\Users\Ptr\Desktop\python\tkinter.py", line 3, in <module>
okno = tkinter.Tk()
AttributeError: module 'tkinter' has no attribute 'Tk'
Process finished with exit code 1
When I try execute that code using IDLE all works.
In PyCharm I try install turtle in project:
Python>Project Interpreter
but all time I have same error:
Collecting turtle
Using cached turtle-0.0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Ptr\AppData\Local\Temp\pycharm-packaging\turtle\setup.py", line 40
except ValueError, ve:
except ValueError, ve:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Ptr\AppData\Local\Temp\pycharm-packaging\turtle\
enter code here
A couple of things to note for those running into this at a later time:
tkinter must be installed on your machine. There is a python2.x and
python3.x version. It must match your version of python. For example,
In Ubuntu, I am running python3.6, and had to run apt-get install
python3.6-tk
Pycharm allows you to pick interpreters. It is possible to be running
a different interpreter in IDLE than in PyCharm, making the mismatch
of python and tkinter versions potentially confusing. This is further
complicated potentially by virtual environments. Be certain your
python version and you tkinter versions match.
You can not have modules in your import path of the name tkinter.py or turtle.py
As mentioned by ds_secret, turtle comes with python, no need to
install it separately.
You don't pip turtle. Turtle is a built-in python package.
You just say import turtle.

Installing RDKit

I have installed Spyder3.2.1 in the current version of Miniconda3 on my Debian v-9.1.0 64 bit Linux platform. Spyder is performing well, but I am having difficulty installing the RDKit.
I followed the directions in the RDKit_Docs_current.pdf:
How to install RDKit with Conda
Creating a new conda environment with the RDKit installed using these
packages requires one single command similar to the following:
$ conda create -c rdkit -n my-rdkit-env rdkit
Finally, the new environment must be activated, so that the
corresponding python interpreter becomes available in the same shell:
$ source activate my-rdkit-env
There were no warning or error messages during the installation, but when I attempt running a simple Python script:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 15 11:41:24 2017
#author: comp
"""
from __future__ import print_function
from rdkit import Chem
m = Chem.MolFromSmiles('Cc1ccccc1')
m
I get:
IPython 6.1.0 -- An enhanced Interactive Python.
runfile('/home/comp/Apps/Python/untitled0.py',
wdir='/home/comp/Apps/Python')
Traceback (most recent call last):
File "<ipython-input-1-3842c59475d8>", line 1, in <module>
runfile('/home/comp/Apps/Python/untitled0.py',
wdir='/home/comp/Apps/Python')
File "/home/comp/Apps/miniconda3/lib/python3.6/site-
packages/spyder/utils/site/sitecustomize.py", line 688, in runfile
execfile(filename, namespace)
File "/home/comp/Apps/miniconda3/lib/python3.6/site-
packages/spyder/utils/site/sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/comp/Apps/Python/untitled0.py", line 10, in <module>
from rdkit import Chem
ModuleNotFoundError: No module named 'rdkit'
RDKit is installed in ~/miniconda3/envs/mr-rdkit-env
Unfortunately, I have no clue as to what the problem(s) may be, assistance will be much appreciated.
Thanks in advance.
If you are using PyCharm try to install RDKit package in File > Settings > Project Interpreter > + , then seach for RDkit to install and use the Python Interpreter where the RDKit is installed or you can reference your ~/miniconda3/envs/mr-rdkit-env/python.exe on your Python Interpreter
switch your currrent python edition to python2.7,you can create a enviroment:conda create -n my_env_name python=2.7

Python- how to install pyvttbl in jupyter notebook

I tried installing it using !pip install
!pip install pyvttbl
and it gives me this message
Requirement already satisfied: pyvttbl
Requirement already satisfied: dictset
Requirement already satisfied: pystaggrelite3
However, when I import it as
import pyvttbl as pt
it gives me
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-89ef5f67d382> in <module>()
----> 1 import pyvttbl as pt
D:\Anaconda3\lib\site-packages\pyvttbl\__init__.py in <module>()
8 # This software is funded in part by NIH Grant P20 RR016454.
9
---> 10 from base import PyvtTbl, DataFrame
11
12 from misc import *
ModuleNotFoundError: No module named 'base'
When I try to install base as
!pip install base
it gives me this
Collecting base
Using cached base-1.0.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\User\AppData\Local\Temp\pip-build-u1xkw0lp\base\setup.py", line 40, in <module>
LONG_DESCRIPTION = read("README.rst")
File "C:\Users\User\AppData\Local\Temp\pip-build-u1xkw0lp\base\setup.py", line 21, in read
return codecs.open(os.path.join(os.path.dirname(__file__), fname)).read()
File "D:\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 5: character maps to <undefined>
Can someone help me understand the problem?
Background
Pyvttbl is no longer actively maintained which is why you are having some difficulty.
I assume that you are using python 3.x and it seems to me that pyvttbl will only work for python 2.7 right now.
Solution
NOTE: only applies to systems running jupyter notebook through Anaconda.
I managed to get this to work in my python 2.7 environment. However I could not reproduce a working install for in a new env. So I exported my py27 env as a .yml file that you can clone through these steps;
1) Download and unzip the .yml env from this gist
2) cd to the location of the unzipped .yml file.
3) Create the clone of my py27 env using the following command;
conda env create -f py27.yml
4) Once conda finishes the install then activate the env;
activate py27
5) Then this env to your list of jupyter notebook kernels with the following;
ipython kernel install --name py27
Now when you start jupyter notebook you can choose to create a py27 notebook when you click the new button. After that you should be able to run pyttbl.
Please comment below if you are still having issues.

Resources