'module' object has no attribute 'utilities' - python

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...

Related

Is there a way to load a fxml into jython logic code?

I need to attach a GUI to python application. I've seen tkinter and Qt5, but they make too native GUIs. In fact, using the first one I cannot customize my elements with css, and the second one only support a subset of it. That's why I wonder if I can use a fxml file to create a nice interface.
Then, I followed this link and tried to use jython. In one comment, they said: "you can manually add jfxrt.jar to your module search path if you are using a version of Java where it isn't available." This is my case, but I have no idea about how to do it. I downloaded the jfxrt.jar and I put it in the same python script folder, but the same error occurs when I try jython script.py:
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper$ReflectiveAccess (file:/usr/share/java/jnr-posix.jar) to method sun.nio.ch.SelChImpl.getFD()
WARNING: Please consider reporting this to the maintainers of jnr.posix.JavaLibCHelper$ReflectiveAccess
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Traceback (most recent call last):
File "./test.py", line 10, in <module>
from javafx.application import Application
ImportError: No module named javafx
What I executed is the code in the page previously linked. What can I do to solve this import error?

RDKit's function MolFromInchi is not working

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.

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.

*.pyd file fails to load, but DependancyWalker comes up clean, and ProcMon shows it loaded

I am trying to load a *.pyd with Python, but I receive the well known "Import Error: DLL load failed: the specified procedure can not be found." error.
I have already done the following:
1.) Investigated the *.pyd with Dependency Walker. GPSVC.DLL and IESHIMS.DLL came up as missing, but delay loaded, IEFRAME.DLL aslo came up as missing an export, but was also delay-loaded. It's my understanding that these are not used, and are delay load anyway, so they should not be the problem.
2.) Did an "import foo" on foo.pyd in the python command window, with ProcMon watching. ProcMon shows event "LoadImage" on "foo.pyd" with result SUCCESS.
This seems to imply that the *.pyd file loaded correctly.
So what am I missing. My windows diagnostics are telling me all is well, but python is telling me the thing cannot be loaded (usually due to a missing dll or symbol).
Ideas?
Thanks!
Is the .pyd file for the same version of Python you're using? Loading a .pyd file for the wrong Python version can produce that error message.
Dependency Walker can show you which pythonNN.dll it links to.
If you have a file foo.pyd, for import foo to succeed, there must be an externally accessible function named initfoo. Dependency Walker will show this (typically the ONLY function) if it exists. initfoo needs to be called by Python to initialise the foo module.
Note: I would expect a more explicit error message if this were the problem:
>>> import fubar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initfubar)
>>>
You say that you are "trying to load a *.pyd file". Is that just a strange way of describing import foo or is it something else?
Did you create the pyd? If not, who did? Have you asked them? Is this pyd available on the web so that others could try to load/import it?
Ok here is the answer:
The windows diagnostics (depends, procmon, etc) were showing the DLL (or pyd) loading fine.
Python was showing that it was not loading fine.
I found that the windows tools were referring to a different Python26.dll hiding in my C:\Window\SysWOW64 folder.
This second Python26.dll (found in SysWOW64) has a symbol that is missing in the primary python26.dll (installed by the windows python installer, found in C:\Python26).
This symbol "_PyByteArray_empty_string", was apparently needed by my *.pyd file.
So when loading via windows diagnostics, the SysWOW64 dll was found, and the *.pyd loaded properly. When loading from python, the dll in C:\Python26\ was found, the symbol was missing, and load failed.
So that is WHY the problem manifested. The question now is: Why are there two versions of Python26.dll floating around, one with _PyByteArray_empty_string, and one without?
I'm using Python 2.6.6. Perhaps this symbol is removed in 2.6.6 but present in some older 2.6.x release?

Categories