libXrender.so.1 not available, aws lambda using rdkit - aws-lambda

Thanks for putting a pip install of rdkit together.
When I went to run my code i observed
Traceback (most recent call last):
File "./app.py", line 12, in <module> from rdkit.Chem import Draw
File "/var/lang/lib/python3.8/site-packages/rdkit/Chem/Draw/__init__.py",
line 21, in <module> from rdkit.Chem.Draw import rdMolDraw2D
ImportError: libXrender.so.1: cannot open shared object file: No such file or directory
normally this could be treated (i think) with
sudo apt-get install libxrender1
based on
albumentations-team/albumentations#415
however, if one wanted to use a docker build (as I do) from some public image such as
FROM public.ecr.aws/sam/build-python3.8:1.71.0-20230124190835
I dont think this is possible.
This thread
https://sourceforge.net/p/rdkit/mailman/rdkit-discuss/thread/CAEmzeFe9Kn6FNeOXmwZqxcdbm7LV1Vz-J9rTw_CJJJRAHgkKfQ#mail.gmail.com/
recommends using a specific conda forge channel.
My plan is to rebuild the docker image using the miniconda base image. I suspect that this might not play well with AWS Lambda/Serverless approaches to app deployment.
I will report back with my workaround. Please let me know if I have missed something.
Thanks.

Core issue was that the base docker image that i chose did not include the libxrender1 package nor the apt-get install command. Setting based image to
FROM python:3.8
resolved the issue

Related

Spyder 5 ModuleNotFoundError

I have just updated my spyder4 to spyder5 as:
conda update spyder
as I try to launch spyder it gives an Error : No module named 'qdarkstyle.colorsystem'
Here is the complete information :
Traceback (most recent call last):
File "/home/sina/anaconda3/envs/py37/bin/spyder", line 11, in <module>
sys.exit(main())
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/app/start.py", line 210, in main
from spyder.app import mainwindow
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 72, in <module>
from spyder.app import tour
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/app/tour.py", line 37, in <module>
from spyder.utils.qthelpers import add_actions, create_action
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/utils/qthelpers.py", line 34, in <module>
from spyder.utils.icon_manager import ima
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/utils/icon_manager.py", line 23, in <module>
from spyder.utils.palette import QStylePalette, SpyderPalette
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/utils/palette.py", line 12, in <module>
from qdarkstyle.colorsystem import Blue, Gray
ModuleNotFoundError: No module named 'qdarkstyle.colorsystem'
I would appreciate any comments on it.
Met with similar problem. I reverted back to previous version till the devs sort the problem out.
conda install spyder=4.2.5
Same problem on Win. To rollback, using miniconda command is the same:
conda install spyder=4.2.5
If you have activated a dedicated environment (named "xyz" here) first go to "base" and update the package repository (in miniconda its conda update conda), then activate the environment you want to operate on. Note: the package repository resides only in "base", however you can have as many custom environments, each installing and running its own version of Sypder (and any other packages installed, dedicated to that environment)
activate base #go to the base to update the package repository first
conda update conda #in miniconda just update conda, not anaconda
activate xyz
conda install spyder=4.2.5
Version 5 reportedly unstable till May-June
For all people that have this problem right now: if you want to use a
very stable and well tested Spyder version, please stay with our
latest version of Spyder 4 (we plan to maintain it for two more months
with small bug fixes). Spyder 5 is still a work in progress and it'll
take us two or three months until reaches the same level of stability.
ccordoba12 https://github.com/spyder-ide/spyder/issues/15113
If you want to play with 5.0 first in a new environment named "tmp":
conda create --name tmp
activate tmp
conda install spyder=5.0.0
Later, can easily blow away that entire environment and everything in it.
conda env remove --name tmp
I tried conda install -c conda-forge qdarkstyle=3.0.2 and it worked. But yeah there are few other bugs but spyder does seem to start.
They notified me that the problem had been fixed and how to get a working version. The remedy is
conda install spyder=5.0.0=*_1
I did so and it is working as expected.
On windows 10 using conda install qdarkstyle=3.0.2
return spyder to ver 4.2.3, but it is working. Anaconda typically fix such a bugs after few days.
I tried downgrading qdarkstyle package using conda install qdarkstyle 2.8.1 and it worked for me. Win 10 64 bit anaconda spyder IDE
On Windows 10 using WinPython and Spyder 5.0.3. I was having this issue with a local module import.
The simple fix was that my PYTHONPATH had gotten reset in the upgrade, and adding back in the relevant folders fixed this.

Python3 cannot find statsmodels.api but I can and so can my linter

I recently got into development with Python running on WSL (Ubuntu 18.04 LTS).
I followed the documentation from here and I'm able to run simple python scripts.
I started playing around with libraries that I installed using the pip3 command such as numpy and pandas and these work fine.
The problem arises when I try to use the statsmodels package.
I've installed it using pip3 install statsmodels
I can see the package in /home/username/.local/lib/python3.6/site-packages/statsmodels I can even see the api.py file in that directory, however, when I type import statsmodels.api as sm as recommended on the statsmodels website I get:
Console output:
username#DESKTOP-1JP4BIE:/mnt/c/users/username/dev/project/playground$ python3 statsmodels.py
Traceback (most recent call last):
File "statsmodels.py", line 5, in <module>
import statsmodels.api as sm
File "/mnt/c/username/chris/dev/project/playground/statsmodels.py", line 5, in <module>
import statsmodels.api as sm
ModuleNotFoundError: No module named 'statsmodels.api'; 'statsmodels' is not a package
I've tried uninstalling and reinstalling (did not work)
I really can't see anything that differentiates this package from the others that I've installed. Does anyone have any insights?
Thanks #Vorsprung durch Technik
The issue was that my file name was statsmodels.py.
I'll remember to be more careful when naming my python files.

Unable to run Autokey Ubuntu 18.04

I am relatively new to Linux/Ubuntu (so please take it easy on me) and I am trying to install Autokey to use the text expansion functionality. I have tried installing it from the instructions on the Github page here - https://github.com/autokey/autokey#installation
However, no matter whether I follow the installation process under the Ubuntu/Mint/Debian section or the instructions to install via pip I cannot seem to get the program working.
The installation seems to be successful (running a 'which' command gives the path installed) but clicking on the icon does not launch the program.
I have also tried to install directly from Ubuntu/GNOME software manager but that also will not launch the program once installed.
I have tried installing both the GTK and QT frontends and neither will launch. I don't get an error message or anything. I have opened up the System Monitor to see if a process even appears (however briefly) and there's nothing.
Typing autokey-gtk into Terminal gives:
/usr/local/lib/python2.7/dist-packages/autokey/gtkapp.py:24: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk, Gdk, GObject, GLib
Traceback (most recent call last):
File "/usr/local/bin/autokey-gtk", line 20, in <module>
from autokey.gtkapp import Application
File "/usr/local/lib/python2.7/dist-packages/autokey/gtkapp.py", line 28, in <module>
import service, monitor
File "/usr/local/lib/python2.7/dist-packages/autokey/service.py", line 21, in <module>
from iomediator import Key, IoMediator
File "/usr/local/lib/python2.7/dist-packages/autokey/iomediator.py", line 107, in <module>
from interface import *
File "/usr/local/lib/python2.7/dist-packages/autokey/interface.py", line 29, in <module>
from Xlib import X, XK, display, error
ImportError: No module named Xlib
Can anyone please help? Thank you.
I am a newbie too and installed Autokey 0.90.4, which did not work for me either. Someone suggested I try 0.95.1 because the other version is 7 years old.
I installed the new version with some acrobatics from the Autokey Github page, using the PIP method. At 1st it did not work, but after doing import setuptools it did. That might be a coincidence since it was after installation of the Ak package itself.
I know this sounds convoluted, but I am not familiar (yet?) with Linux. Anyway 0.95 works for me.
install module python-xlib and it will work, like this:
On Deb:
apt install python3-xlib
You might later need python autokey module as well:
pip install autokey

Problems finding modules after installing SimpleCV 1.3

I have recently installed SimpleCV on Windows 10 from the superpack. Everything went well during the installation, and I was able to successfully run the first example problem in "Practical Computer Vision with SimpleCV" (good book, btw) from within IDLE. Here's the code:
from SimpleCV import Camera, Display, Image
cam = Camera()
display = Display()
img = cam.getImage()
img.save(display)
Simple enough, and it worked fine. Where I ran into problems was when I tried to start up the SimpleCV console. First of all, no link was created on the Windows desktop, and there was nothing for SimpleCV on the Start menu. So, I tried the other methods listed in the book. First, from the console, I tried to run it as a Python module:
C:\User> python -m SimpleCV.init
And what I got back was:
ERROR:
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\lib\site-packages\SimpleCV\__init__.py", line 18 in <module>
from SimpleCV.Shell import *
File "C:\Python27\;ib\site-packages\SimpleCV\Shell\__init__.py", line 1, in <module>
from Shell import *
File "C:\Python27\lib\site-packages\SimpleCV\Shell\Shell.py", line 54, in <module>
raise(e)
ImportError: No module named IPython
Next, I tried the listed alternative: just starting python and importing and executing the Shell. Entering:
>>> from SimpleCV import Shell
resulted in the same error as above.
I also tried installing ipython by running pip. But, it looks like pip didn't get installed either.
So, what environmental variable did the installation program not set correctly? Just so you know, I posted this same question on the SimpleCV site, but have not received a response as of yet.
--- 23 Dec 2015
Chipping away at this. Read the banner on setuputils install. Ran Python27\Scripts\easy_install.exe. Can now call pip. However, entering this at the command line:
C:\Users> pip install ipython
gives this error:
C:\Python27\lib\site--packages\pip-7.1.2-py2.7.egg\pip\_vendor\requests\packages\urllib3\util\ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cuase certain SSL connections to fail. For more information, see...
So, I'm making progress. Any suggestions?
Have you tried to install ipython from source code?
$ tar -xzf ipython.tar.gz
$ cd ipython
$ python setup.py install
See https://ipython.org/ipython-doc/3/install/install.html
There are a lot of requirements more. I recommend the SimpleCV's github repository instructions https://github.com/sightmachine/SimpleCV#windows-8

pip install --user error under OS X (virtualenv doesn't fix it)

I used to install python (2.7.6) packages using sudo pip install [...] until I recently decided that this was a bad idea and I should use: pip install --user [...] instead.
Since I am using Mac OS X (10.10.3), my python modules had been installed into /Library/Python/2.7/site-packages. Now, with the --user option enabled, they are being installed into: /Users/USER/Library/Python/2.7/lib/python/site-packages
I have since moved all packages (including pip/setuptools) into this destination, adjusted my $PYTHONPATH and changed the file ownership to my local user. I expected that I would now be able to call pip install --user [..] and everything should go smoothly.
Unfortunately, this is not the case. For any pip install (or pip install --upgrade) command I receive the same error (below). The same is true when using a virtualenv - the same error shows up and I have no clue why.
However, everything does work "fine", when I use sudo pip install --user, which is why I assume that it is somehow related to a file-permission error I can not see. (It's not exactly fine, as the newly installed package will be in the right location, but all files are owned by root.)
Any idea what I am doing wrong or how to debug this?
pip install --upgrade --user tornado
Collecting tornado
Using cached tornado-4.1.tar.gz
Exception:
Traceback (most recent call last):
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/commands/install.py", line 280, in run
requirement_set.prepare_files(finder)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 317, in prepare_files
functools.partial(self._prepare_file, finder))
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 304, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 483, in _prepare_file
abstract_dist.prep_for_dist()
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 123, in prep_for_dist
self.req_to_install.run_egg_info()
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_install.py", line 368, in run_egg_info
self.setup_py, self.name,
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_install.py", line 339, in setup_py
import setuptools # noqa
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extension import Extension
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
I also checked the location of pkg_resources and deleted pkg_resources.pyc, which is located in /usr/local/lib/python2.7/site-packages for some reason, but it didn't change anything. (My local user also has full access rights in this location.)
[UPDATE:]
For some reason I was able to install virtualenv without root (pip install --user virtualenv), but all other packages I tried still fail. Also, if I switch to a new virtual environment, I still receive the same error. I am now thinking this is related to my $PYTHONPATH variable, which appears to not be updated for my virtualenv, but I haven't found the real solution, yet.
Alright, so I found the actual problem and solution. My $PYTHONPATH contained an invalid directory. I setup my $PYTHONPATH a long time ago and wrote it into a .bashrc (or more accurately .bash_profile) script.
pip was probably looking through all directories in $PYTHONPATH, although I don't know what it is doing in each of them that causes the above error, but removing the invalid directory fixed my problems.
I also now highly recommend to just use virtualenv instead of a static setup.

Resources