RDKit's function MolFromInchi is not working - python

I am currently working on a Django project that necessitates the functionality of taking an InChI string and converting it into a molecule, but the package that I'm using seems to have an issue with its function MolFromInchi. Whenever I try to use this function, python tends to generate this traceback:
Ex.
>>> from rdkit.Chem.inchi import MolFromInchi
>>> mol = MolFromInchi('InChI=1S/O2Si/c1-3-2')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\tcherry\repos\dataslate_django\venv\my-rdkit-env\lib\site-packages\rdkit\Chem\inchi.py", line 71, in MolFromInchi
mol, retcode, message, log = rdinchi.InchiToMol(inchi, sanitize, removeHs)
TypeError: No to_python (by-value) converter found for C++ type: class boost::shared_ptr<class RDKit::ROMol>
This error seems to be derived from the source code of the rdkit package, but I was wondering if there's anything that I can do to circumvent or mitigate this issue while still being able to incorporate the functionality of MolFromInchi into my project.
NOTE: I was able to reproduce this error after following the instructions on how to install RDKit with Conda posted on the RDKit Documentation, and this question pertains to the most current version of RDKit (2020.03.1).

It turns out that the reason I came across that issue is because whenever you make changes to the source code (which I've done to address a different issue with my project), those changes influence the .conda cache folder, meaning that if you were to ever uninstall and reinstall a conda package, the installation process would refer to the cache folder.

Related

'module' object has no attribute 'utilities'

Trying to implement ytini (yt for Houdini) Python framework.
http://www.ytini.com/
Resolved most install erros but am still getting the following when I load a datfile
Not sure if this might be related to some configuration for ytini or if its more of a Python specific error.
Traceback (most recent call last): File "", line 14,
in File "/home/jim/.local/lib/python2.7/site-packages/yt/__init__.py", line 44,
in import yt.utilities.physical_constants as physical_constants
AttributeError: 'module' object has no attribute 'utilities
Can any Python experts suggest any troubleshooting steps?
Update>
If I simply do an import yt I get the following error
Warning! HDF5 library version mismatched error
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
'HDF5_DISABLE_VERSION_CHECK' environment variable is set to 1, application will
continue at your own risk.
Headers are 1.10.0, library is 1.8.11
This error means that you are treating yt.utilities as an object from which you are trying to access the object attribute physical constants, which is correct, but python thinks that this attribute doesn't exist. However, I am unable to reproduce this error and can access the values stored therein. What else is in your code? It looks like you are accessing another module function of yt which uses the constants attributes, is that correct? Also, are you using python 2.7 or 3.x?
In terms of installing package in 2 different places, I've had this happen before which was very frustrating, but the folders can be found by doing a folder search for the module name and should return all versions saved in different locations. The exact location of the modules varies with IDE, OS, weather...

Python 3: Deleted everything related to an API I already installed, now that I reinstalled it Python can't find the functions defined in the API

I downloaded the Podio API for Python and after something like ten tries I got it installed, by then I had already downloaded it 3 times from different sources, and when I got errors later (since apparantly I had downloaded and installed the Python 2-version) I was very confused and wanted to simply undo everything and install it correctly without all the crap. I tried uninstalling but it didn't work (partly I think because I don't know which method of installing it was actually successful, it just worked all of a sudden), so I just deleted everything and hoped that would at least disable it. After doing that I installed again it by typing this (relevant since I someone told me the pip-version wasn't updated, but the github-version was, and told me to type this instead. I don't understand the difference since it still says 'pip install') in the CMD:
pip install -e git+https://github.com/podio/podio-py.git#egg=podio-py
now I get this error:
from pypodio2 import OAuthClient
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from pypodio2 import OAuthClient
ImportError: cannot import name 'OAuthClient'
What causes the problem? Two days of issues with this API.
OAuthClient is accessible via pypodio2.api. Change your import statement to:
from pypodio2.api import OAuthClient
client = OAuthClient('api_key', 'api_secret', 'login', 'password')

Error getting Python script to run on older version

I had tested a web based application which uses Python (2.7.8) scripts to create a dynamic content.
I am parsing some XML data and performing several operations on it.
One of the operations requires searching certain type of data which uses the findall(xpath) function from ElementTree.
Now the place where I need to deploy is a Linux box which has an older version of Python (2.6.6).
I had some trouble due to the older ElementTree not having certain capabilities.
I followed this ElementTree SyntaxError: expected path separator ([). I copied the ElementTree from 2.7.8 to the new box and imported from there.
It imports fine but now I get a different error which is as follows:
Traceback (most recent call last):
File "./filename_python.py", line 117, in <module>
for ch in child.findall(xpath):
File "/usr/lib64/python2.6/xml/etree/ElementPath.py", line 293, in findall
return list(iterfind(elem, path, namespaces))
File "/usr/lib64/python2.6/xml/etree/ElementPath.py", line 194, in select
if "".join(e.itertext()) == value:
AttributeError: itertext
I cannot update the Python version on that box and I cannot add any modules so anything new has to be imported locally.
Any help is appreciated.
Thank you.
It doesn't seem to me that you've backported the 2.7.x version library properly. Take a look at the stack trace and you will see it is still referring to the library in your Python 2.6.x path:
/usr/lib64/python2.6/xml/etree/ElementPath.py
You could also consider lxml - you don't need to install it as a system library. Simply clone from the git repository here, and copy the code into your projects directory.

Versioning module in python missing

When i compile s3cmd, I found Versioning module is missing, stacktrace as:
Traceback (most recent call last):
File "./s3cmd", line 1983, in <module>
from S3.S3 import S3
File "/home/chutong/s3cmd.svn/S3/S3.py", line 29, in <module>
from Versioning import Versioning
ImportError: No module named Versioning
I tried to check online and there is not much resource? Can someone please help? Thanks
I just checked the source for s3cmd on github. It appears it no longer imports this module nor does it contain a module named Versioning in its code tree.
Without more information I can't tell, but what I would suspect is you have a version mismatch, perhaps one version installed in your Python environment and another one locally.
It's a bit odd that it's raising the exception from an SVN directory, but like I say, will need more information about your execution environment to make any headway. Things like current directory, a dump of sys.path, that sort of thing.
But if it's possible, you might try updating the installed version and trying again. Looks like the library has had some significant updates since the version you appear to be using.

Trouble importing Python modules on Ninja IDE

I have been trying to import modules into Ninja IDE for python. These are modules that I have working on the terminal (numpy, scipy, scitools, matplotlib, and mpl_toolkits), but will not run correctly in Ninja.
First I was only getting the message No module named ____. I checked sys.path and found that the path was within the application
/Applications/Ninja IDE.app/Contents/Resources/lib/python2.7 was a typical path. I tried changing the path,but it doesn't seem to do anything to sys.path even after restarting the ide.
But I wanted the path to refer to where the modules are stored (which is /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages). I was able to get numpy and scipy to work as well as parts of mpl_toolkits by adding the contents of my path to the folders that sys.path gave. However, I still can't get fully functioning modules within the ninja ide interpreter. I'll give some examples below of what happens when I import certain modules.
import matplotlib.pyplot
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Applications/Ninja IDE.app/Contents/Resources/lib/python2.7/matplotlib/__init__.py", line 106, in <module>
ImportError: No module named sysconfig
import mpl_toolkits
from mpl_toolkits.mplot3d import axes3d
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Applications/Ninja IDE.app/Contents/Resources/lib/python2.7/mpl_toolkits/mplot3d/__init__.py", line 1, in <module>
File "/Applications/Ninja IDE.app/Contents/Resources/lib/python2.7/mpl_toolkits/mplot3d/axes3d.py", line 14, in <module>
File "/Applications/Ninja IDE.app/Contents/Resources/lib/python2.7/matplotlib/__init__.py", line 106, in <module>
ImportError: No module named sysconfig
Thanks for the help. I apologize, I am very new to programming, but I did put in about a day and a half of research before posting here.
That's strange as the sysconfig module is a part of Python 2.7 standard library.
Are you sure that Ninja is using the right Python version? Try running:
import sys
print sys.version_info
from Ninja, to see which Python version it is actually using.
I know this question is a few months old, but I wanted to post my solution in case others find it useful. I had a very similar problem, and had a lot of trouble finding a quick workable solution anywhere.
My somewhat roundabout solution was to simply create a virtualenv folder with the version of numpy I wanted, and then pointed the "virtualenv" property for NinjaIDE project to that folder. I restarted NinjaIDE and boom, instantly worked.
To set the virtualenv property for your project via the GUI, go to the Project menu:
Project > Open Project Properties > Project Execution,
and you should see a variable called "Virtualenv Folder". Point that to the folder for your virtualenv, and it should work. (May need to restart NinjaIDE.) This worked for me, NinjaIDE version 2.2 under Ubuntu 12.04.
One quick note: I actually didn't use virtualenv exactly -- I had to use a "conda env," since I am using the Anaconda distribution, and apparently it is not well-tested with virtualenv yet. (I actually got a warning when I went to easy_install virtualenv. Hadn't seen that before.)
Either way, this stackoverflow question has some nice pointers to virtualenv tutorials: Comprehensive beginner's virtualenv tutorial?
Good luck!
I was having a similar problem trying to import a module from /home/paul/lib/python using the console of the Ninja-IDE. I found out that /home/paul/lib/python didn't appear in syspath when checking in the console of the Ninja-IDE. But it did in the terminal!
By starting the Ninja-IDE from the terminal, /home/paul/lib/python was in syspath when checking in the console of the Ninja-IDE. I was now able to import the module I needed.
I hope this might be of some help. If not to ebris1 than maybe to others.

Categories