MEEP FDTD libEGL warning: DRI2: failed to authenticate - python

I have a fresh install of MEEP (the FDTD package) in a Conda environment, on a fresh install of elementaryOS. I'm attempting to run the "Visualizing 3D Structures" example code found here. I've installed both both pymeep and pymeep-extras, as well as scikit-image and vispy (dependencies for the example code).
Running python3 visualizing_3d_structures.py within the Conda environment yields the error libEGL warning: DRI2: failed to authenticate, and no graphical display appears. A simple Google search reveals a number of StackExchange posts (with various, at times contradictory advice) relating to a similar issue specific to Raspbian. none of which seems relevant here, unfortunately.

This could happen if there isn't a backend (software graphic device) installed in the environment, but there is a libEGL installed at the system-level (EGL is one of the backends for which MEEP will search).
The recommended backend for MEEP is PyQt, so installing that should be sufficient get it working:
conda install -c conda-forge pyqt
That works for me. However, the tutorial directly recommends mayavi. This will also install pyqt, but obviously has extra stuff as well. So, if you want to strictly follow the tutorial, then run
conda install -c conda-forge mayavi
I verified that also gets it working.

Related

No module found error for a downloaded package (sksparse.cholmod) and how to download a package from the internet to conda

I need to use the sksparse.chomod package however my pycharm does not let me install it as it can't seem to find it.
I found the sksparse package on github and downloaded it but I do not know how to add a package downloaded from the internet into a conda environment. So, my first question would be can you download a package from github and add it to your conda environment, and how do you do this?
As I did not know how to do the above I instead saved the package within my project and thought I could simply import sksparse.cholmod. However, the line in my code that says import sksparse.cholmod as sks has no errors with it, so I assumed that meant this was ok, but when I try to run my file I get this error:
import sksparse.cholmod as sks
ModuleNotFoundError: No module named 'sksparse.cholmod'
If I have downloaded the package into my project why can't it be found, yet there are no errors when importing?
The cholmod file is a pyx file which I've been told should not be a problem.
Please could anyone help, I am reasonably new to python and I am looking for a straight forward solution that won't be time consuming.
It was an issue with windows, I was able to fix this using the instructions on this link
https://github.com/EmJay276/scikit-sparse
We must follow these steps precisely:
(This was tested with a Anaconda 3 installation and Python 3.7)
Install these requirements in order:
'''
conda install -c conda-forge numpy - tested with v1.19.1
conda install -c anaconda scipy - tested with v1.5.0
conda install -c conda-forge cython - tested with v0.29.21
conda install -c conda-forge suitesparse - tested with v5.4.0
'''
Download Microsoft Build Tools for C++ from https://visualstudio.microsoft.com/de/visual-cpp-build-tools/ (tested with 2019, should work with 2015 or newer)
Install Visual Studio Build Tools
Choose Workloads
Check "C++ Buildtools"
Keep standard settings
Run ''' pip install git+https://github.com/EmJay276/scikit-sparse '''
Test ''' from sksparse.cholmod import cholesky '''
Use all the versions stated for numpy etc, however with scipy I installed the latest version and it worked fine.

opencv: Could not load the Qt platform plugin "xcb" in "" even though it was found

I installed opencv-python on ubuntu wsl, after setting up a venv using virtualenvwrapper (I use wsl in visual studio code).
When running this code (which appears in one of the articles of this OCR guide:
import argparse
import cv2
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True)
args = vars(ap.parse_args())
image = cv2.imread(args["image"])
cv2.imshow("I", image)
with this command on teminal:
python script.py --image temp.png
I get:
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/ben123/.local/bin/.virtualenvs/ocr_venv/lib/python3.8/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb.
The interpreter in vscode is the correct one (the one of the venv), and when I type pip list I get
Package Version
------------- --------
numpy 1.22.2
opencv-python 4.5.5.62
pip 22.0.3
setuptools 60.6.0
wheel 0.37.1
Would appreciate any help at this point, since I spent so much time and didn't get nowhere.
Things I tried:
following this guide to install it. Gave the same error.
following an older guide from this site, was much more complicated and didn't work as well.
uninstalling opencv-python and installing opencv-python again/ opencv-python-contrib/ opencv-python-headless/ opencv-python-contrib-headless (only one of them at a time)
following this thread because it has similar problem
literally reset my wsl several times just to make sure I don't have multiple pythons/ opencv versions that mess this up.
tried installing (to a wsl venv) opencv directly with the official documentation
Tried to give up on wsl completely and install opencv using anaconda but even that didn't work.
Just delete cv2.imshow from your code. Your OS is without graphics and can't display image
I had the same error in a completely different context.
Found that the problem was a PyQt5 installation in my virtual environment.
Check if you have a PyQt in the path
/home/ben123/.local/bin/.virtualenvs/ocr_venv/lib/python3.8/site-packages/
if so, remove it
$ pip uninstall <PyQT package installed>
example:
$ pip uninstall PyQt5
Then reinstall opencv-python
$ pip uninstall opencv-python
$ pip install opencv-python
Hope that works!
To display graphical information about wsl, you should configure x11 related content.
eg: You can use MobaXterm for graphical display.
Uninstalling opencv and installing similar headless version worked for me.
$ pip install opencv-python-headless

Can't install Matplotlib on macOS Big Sur

Since I've upgraded my MacOs to Big Sur I'm having some trouble with my data science libraries. I was able to install the numpy and pandas (even though it took an unusual amount of time as stated at this topic). But can't manage to install the Matplotlib.
I've tried three things...
First with the default MacOs embedded Phyton 3.8.2 .
Reinstalled numpy, upgraded pip, but when I've tried to install Matplotlib. I've got the following error:
RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned
Later, I've seen some suggestions here at stackoverflow for similar problems, one suggested to use homebrew, so I've installed Python 3.9.0 through brew. However, when I've tried to install Matplotlib, still got a giant error, when it was trying to install Pillow:
(.......) The headers or library files could not be found for jpeg,a required dependency when compiling
Pillow from source.Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
ERROR: Command errored out with exit status 1: /usr/local/opt/python#3.9/bin/python3.9 (...)
To finish (in almost despair) I've tried to create a virtual environment using venv (& Python 3.8.2) and was able to install NumPy successfully, however, I've got the following error trying to install Matplotlib:
(...... long line of code....) The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.
This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand. Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.
Really don't know what to do... Is it impossible to use Matplotlib with a clean install on BigSur? hahaha =(
I did it!!! I fix it!!
For this error :
RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend.
If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned
I fixed installing an older numpy version.
pip3 install --force-reinstall numpy\<1.19
It did the job.
For the second error:
(.......) The headers or library files could not be found for jpeg,a required dependency when compiling
Pillow from source.Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html
ERROR: Command errored out with exit status 1: /usr/local/opt/python#3.9/bin/python3.9 (...)
It was the missing JPEG library. I do recommend you guys install homebrew.
Solved this problem with:
brew install libjpeg
your easy_install is outdated.so just update your setup_tools by excuting following command:
pip install setuptools==51
then
easy_install --version
make sure your easy_install's version is above 51.

Windows 10 - Anaconda 2020.02 - GTK installation fails, gdk-pixbuf

Using the solution from:
Ubuntu - Anaconda 2020.02 - Namespace Gtk not available
and trying this on a Windows 10 system (again, Anaconda 2020.02) a different problem appeared.
An error box pops up, titled 'gdk-pixbuf-query-loaders.exe - Entry Point Not Found', with the text: The procedure entry point libiconv_set_relocation_prefix could not be located in the dynamic link library C:\Users\Me\Anaconda3\Library\bin\glib-2.0.0.dll
The text on the console shows up as 'An error occurred while installing package 'conda-forge::gdk-pixbuf-2.38.2-h67ea0bb_3'
Not too sure what is going on, again. It would seem that Anaconda thinks these are OK:
https://anaconda.org/search?q=gtk3
https://anaconda.org/search?q=gdk-pixbuf
Installation of gdk-pixbuf seems to be the sticking point, as that fails to install.
Trying to install with 'conda install -c conda-forge gtk3=3.24.14=ZZZZZZZZ' and ZZZZZZZZ are the two different builds yields the same error.
Additional information:
A clean install of Anaconda, with no updates, only:
conda install -c conda-forge gtk3
... still yields problems (lots and lots of conflicts), and the original answer (to install glib) did not consistently solve the problem.

pystan: CompileError: command 'gcc' failed with exit status 1 (Windows)

Before I get to far into this, I should note that I have seen a very similar question, but the solution presented did not work for me. Perhaps one reason why is because that was Linux build and my current difficulty is on a Windows 7 machine. I use Cygwin to get access to the gcc (5.2.0) compiler suite.
In any event, I have been attempting to try out Stan via PyStan. I am working with an Anaconda (2.4.1 64-bit) distribution which I just updated today (Python 2.7.11). I initially tried to install PyStan via pip, but the install keeps failing due to what looks like the following error:
Cannot build msvcr library: "msvcr90d.dll" not found
Consequently, I used conda instead, which seemed to install just fine. (I should note that the conda install pushed my numpy back to an earlier version, which created conflicts with the pandas upon import. I just updated anaconda to deal with these broken dependencies.) I was also able to import PyStan without any problems. However, when I actually tried to fit a model (inside of a Jupyter Notebook), the process failed with the exception in the title.
The first thing I did was confirm that gcc was where in the referenced location (not shown in the title). Indeed it was, and it seemed to working just fine. I then tried to run the model as a script from the command line (still using Python), and it failed with the same error. When I recreated the model via the REPL, it pointed to a different location that had a .bat file referencing the (verified) compiler, and that failed as well.
I am pretty sure this is because I have Visual Studio 2012, instead of Visual Studio 2008. While it is possible for me to run parallel installations, if this code is going to be useful for others in the future, these are not reasonable hoops to jump through to make it happen. I was hoping that someone else might have a better explanation. Any info would be greatly appreciated.
Beneficial from the post at https://github.com/stan-dev/pystan/issues/306
I have met various error message, but finally, I install PyStan successfully.
My machine is also on Windows 7, x64 with Anaconda3 installed.Here are the procedures to install PyStan from the sourced codes.
Install Visual Studio 2017 & Visual Studio C++ Build Tool 2015 at http://landinghub.visualstudio.com/visual-cpp-build-tools
Update Conda
conda update conda
conda update --all
check the dependencies
pip install setuptool
conda install numpy cython matplotlib scipy pandas
Install gcc compiler components
conda install libpython
conda install -c msys2 m2w64-toolchain=5.3.0
created distutils.cfg file inside Anaconda3\Lib\distutils folder with the following:
[build]
compiler = mingw32
Download Git at https://git-scm.com/downloads
git clone --recursive https://github.com/stan-dev/pystan.git
Compile from the source code
python setup.py build --compiler=mingw32
python setup.py install
P.S. The solution for the issue: Cannot build msvcr library: "vcruntime140d.dll" not found.
Copy vcruntime140d.dll from C:\Windows\System32 to any folder, which is reachable in the path in the advanced system settings/environment variables/ system variables.

Categories