Last active
February 3, 2022 18:41
-
-
Save philopon/a75a33919d9ae41dbed5bc6a39f5ede2 to your computer and use it in GitHub Desktop.
DEPRECATED. Please use https://pypi.org/project/rdkit-pypi/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import requests | |
import subprocess | |
import shutil | |
from logging import getLogger, StreamHandler, INFO | |
logger = getLogger(__name__) | |
logger.addHandler(StreamHandler()) | |
logger.setLevel(INFO) | |
def install( | |
chunk_size=4096, | |
file_name="Miniconda3-latest-Linux-x86_64.sh", | |
url_base="https://repo.continuum.io/miniconda/", | |
conda_path=os.path.expanduser(os.path.join("~", "miniconda")), | |
rdkit_version=None, | |
add_python_path=True, | |
force=False): | |
"""install rdkit from miniconda | |
``` | |
import rdkit_installer | |
rdkit_installer.install() | |
``` | |
""" | |
python_path = os.path.join( | |
conda_path, | |
"lib", | |
"python{0}.{1}".format(*sys.version_info), | |
"site-packages", | |
) | |
if add_python_path and python_path not in sys.path: | |
logger.info("add {} to PYTHONPATH".format(python_path)) | |
sys.path.append(python_path) | |
if os.path.isdir(os.path.join(python_path, "rdkit")): | |
logger.info("rdkit is already installed") | |
if not force: | |
return | |
logger.info("force re-install") | |
url = url_base + file_name | |
python_version = "{0}.{1}.{2}".format(*sys.version_info) | |
logger.info("python version: {}".format(python_version)) | |
if os.path.isdir(conda_path): | |
logger.warning("remove current miniconda") | |
shutil.rmtree(conda_path) | |
elif os.path.isfile(conda_path): | |
logger.warning("remove {}".format(conda_path)) | |
os.remove(conda_path) | |
logger.info('fetching installer from {}'.format(url)) | |
res = requests.get(url, stream=True) | |
res.raise_for_status() | |
with open(file_name, 'wb') as f: | |
for chunk in res.iter_content(chunk_size): | |
f.write(chunk) | |
logger.info('done') | |
logger.info('installing miniconda to {}'.format(conda_path)) | |
subprocess.check_call(["bash", file_name, "-b", "-p", conda_path]) | |
logger.info('done') | |
logger.info("installing rdkit") | |
subprocess.check_call([ | |
os.path.join(conda_path, "bin", "conda"), | |
"install", | |
"--yes", | |
"-c", "rdkit", | |
"python=={}".format(python_version), | |
"rdkit" if rdkit_version is None else "rdkit=={}".format(rdkit_version)]) | |
logger.info("done") | |
import rdkit | |
logger.info("rdkit-{} installation finished!".format(rdkit.__version__)) | |
if __name__ == "__main__": | |
install() |
Well, the installation was complete. But why am I not able to access 'Chem' subpackage from rdkit? The only modules available from the installation are ['RDConfig',
'RDPaths',
'kernel_name',
'logger',
'logging',
'rdBase']
According to the rdkit documentation, there are so many subpackages but I am unable to access them!
Is this up to date? This does not work for me. I am getting below error:
CalledProcessError: Command '['/root/miniconda/bin/conda', 'install', '--yes', '-c', 'rdkit', 'python==3.7.12', 'rdkit']' returned non-zero exit status 1.
This script is DEPRECATED.
Please use rdkit-pypi package.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I was trying to install rdkit using above code. But, got this error. Any help please !!!!
CalledProcessError Traceback (most recent call last)
in ()
84
85 if name == "main":
---> 86 install()
1 frames
in install(chunk_size, file_name, url_base, conda_path, rdkit_version, add_python_path, force)
76 "-c", "rdkit",
77 "python=={}".format(python_version),
---> 78 "rdkit" if rdkit_version is None else "rdkit=={}".format(rdkit_version)])
79 logger.info("done")
80
/usr/lib/python3.7/subprocess.py in check_call(*popenargs, **kwargs)
361 if cmd is None:
362 cmd = popenargs[0]
--> 363 raise CalledProcessError(retcode, cmd)
364 return 0
365
CalledProcessError: Command '['/root/miniconda/bin/conda', 'install', '--yes', '-c', 'rdkit', 'python==3.7.10', 'rdkit']' returned non-zero exit status 1.