Installing RDKit - python-3.x

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

Related

Packages doesn't set up on python venv

I'm trying to build pyslam project, and the install.sh file was provided. But when I executed install.sh, the main.py didn't work.
https://github.com/luigifreda/pyslam#install-pyslam-under-ubuntu-2004
Full Installation
In order to run main_slam.py with venv, get in the root of this repository and run the following command:
$ . install_all_venv.sh
N.B.: do not forget the dot! (without '/' !)
This will compile the required thirdparty packages and will also activate the created pyslam environment. Now, from the same terminal, you can run:
$ python3 -O main_slam.py
The result was
(pyslam) (base) ict-526#ict526-MS-7D32:~/pyslam$ python3 -O main_slam.py
Traceback (most recent call last):
File "/home/ict-526/pyslam/main_slam.py", line 27, in <module>
from config import Config
File "/home/ict-526/pyslam/config.py", line 27, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
I think the packages didn't install in the venv (pyslam). How can I fix this situation?
My environment is ubuntu20.04, and python 3.9.7.
According to the installaion instruction, python 3.6.9 was required. After install_all_venv.sh, the pyslam venv support python 3.9.7...

Can't create virtual env with Python 3.9 in Windows

I have installed both Python 3.7 and 3.9 in my Windows 10 using Microsoft Store, which put both python files in \Users\me\AppData\Local\Microsoft\WindowsApps:
The problem is that, when I try to create a virtual env with Python 3.9 using python3.9 -m venv venv, I get this error:
Could not import runpy module
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 14, in <module>
import importlib.machinery # importlib first so we can test #15386 via -m
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 51, in <module>
_w_long = _bootstrap_external._w_long
AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long'
I read that this happens because it is trying to use pip3.7, but I can't find how to instruct python to use pip3.9.
Unset the $PYTHONPATH environment variable. That is what is causing python3.9 to incorrectly find code inside Python-3.7.
set PYTHONPATH=
python3.9 -m venv .venv

Having problems installing python-docx

>>> import docx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\users\kevin\mu_code\docx\__init__.py", line 3, in <module>
from docx.api import Document # noqa
File "c:\users\kevin\mu_code\docx\api.py", line 14, in <module>
from docx.package import Package
File "c:\users\kevin\mu_code\docx\package.py", line 9, in <module>
from docx.opc.package import OpcPackage
File "c:\users\kevin\mu_code\docx\opc\package.py", line 9, in <module>
from docx.opc.part import PartFactory
File "c:\users\kevin\mu_code\docx\opc\part.py", line 12, in <module>
from .oxml import serialize_part_xml
File "c:\users\kevin\mu_code\docx\opc\oxml.py", line 12, in <module>
from lxml import etree
ImportError: cannot import name 'etree'
I have python-docx 0.8.10 and lxml 4.5.0, windows 10. I tried googling already but I'm not sure if I followed the suggestions correctly or if it's applicable in my case (lxml problems). I haven't had any problems installing other modules using "pip install" so I'm stuck and don't know how to proceed from here.
Check this,
Use pip install, to install the docx library and if you have already install it successfully then have a look into its dependencies. I think it is because of the incompatibility with its dependencies that is why you are getting the error.
pip install python-docx
Dependencies
Python 2.6, 2.7, 3.3, or 3.4
lxml >= 2.3.2
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 an environment according to your needs. For your case create an environment for Python 3.4 using the following command
conda create --name py34 python=3.4
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.
Kindly refer to the link. Hope this helps you.
This is almost certainly a problem with the lxml install. python-docx works with all versions of Python >= 2.6.
Instead of import docx, try from lxml import etree. If this produces the same error message, you know you've narrowed it down.
lxml depends on a couple of C libraries, lib2xml and libxslt if I remember correctly. These are sometimes tricky to install. In any case, you'll find solutions to those problems by searching on "lxml install windows" or similar.
Once from lxml import etree works without error I think you'll find import docx does too.

AWS CLI in CMD and PowerShell

On Win 10 I've installed Anaconda (via chocolatey) and the AWS CLI. I can successfully issue commands via the AWS CLI as long as I'm in one of the following:
an Anaconda prompt
a Git Bash prompt
the powershell terminal inside of visual studio code
However, when I try to issue commands from a "straight-up" CMD or PowerShell window, then I get errors:
C:\>aws s3 ls
Traceback (most recent call last):
File "c:\Users\barias\AppData\Roaming\Python\Python37\Scripts\aws.cmd", line 50, in <module>
import awscli.clidriver
File "C:\Users\barias\AppData\Roaming\Python\Python37\site-packages\awscli\clidriver.py", line 17, in <module>
import botocore.session
File "C:\tools\Anaconda3\lib\site-packages\botocore\session.py", line 30, in <module>
import botocore.credentials
File "C:\tools\Anaconda3\lib\site-packages\botocore\credentials.py", line 34, in <module>
from botocore.config import Config
File "C:\tools\Anaconda3\lib\site-packages\botocore\config.py", line 16, in <module>
from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS
File "C:\tools\Anaconda3\lib\site-packages\botocore\endpoint.py", line 22, in <module>
from botocore.awsrequest import create_request_object
File "C:\tools\Anaconda3\lib\site-packages\botocore\awsrequest.py", line 26, in <module>
import botocore.utils
File "C:\tools\Anaconda3\lib\site-packages\botocore\utils.py", line 31, in <module>
import botocore.httpsession
File "C:\tools\Anaconda3\lib\site-packages\botocore\httpsession.py", line 7, in <module>
from urllib3.util.ssl_ import (
ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_' (C:\tools\Anaconda3\lib\site-packages\urllib3\util\ssl_.py)
I am not a Python programmer, so it is not self-evident what this error means.
A side commentary on my Anaconda install:
I am surprised to see Anaconda installed in C:\tools. I think that is because (1) my chocolatey script which installed Anaconda was executed inside that folder and (2) the Anaconda chocolatey package perhaps was designed to install in the current working directory? Regardless, I don't think this problem is a result of where Anaconda is installed.
I also found that I had to manually put the python exe onto the path. I'm not sure why the Anaconda install didn't do that for me.
As it turns out, I can successfully issue terraform commands from CMD or PowerShell to that same AWS account. I would have thought if the AWS CLI wasn't working, then terraform would be hosed as well. Weird.
None of the prompts (Git Bash, Anaconda, CMD, PowerShell) have PYTHONPATH OR PYTHONHOME environment variables set. The Anaconda path has these environment variables:
CONDA_DEFAULT_ENV=base
CONDA_EXE=C:\tools\Anaconda3\Scripts\conda.exe
CONDA_PREFIX=C:\tools\Anaconda3
CONDA_PROMPT_MODIFIER=(base)
CONDA_PYTHON_EXE=C:\tools\Anaconda3\python.exe
CONDA_SHLVL=1
I tried setting these in the CMD window, but it did not fix the problem. Also, the Git Bash prompt successfully handles the AWS CLI...and it doesn't have any environment variables configured regarding python or "conda".
Any ideas of why I'm getting this error? Remember, it works fine as long as I execute commands from an Anaconda prompt.

No longer able to launch Spyder since updating PyQt5 via pip

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.

Resources