How to customize python libz.so.1 reference in linux system - python

I'm currently using linux system.
I have a simple python GUI code that uses matplotlib library. My IDE is spyder(Anaconda) and this python code work well.
The problem is when I run this code on linux console ( $ python my_matplotlib_gui.py)
(Of course other simple python codes work well.)
This command give this error code:
======================
Import error: /lib/libz.so.1: version 'ZLIB_1.2.9' not found (required by /user/mysys/anaconda3/lib/python3.7/site-packages/matplotlib/libpng16.so.16)
======================
I recognized that this problem arouse from the fact that the /lib/libz.so.1 is linked to the zlib_1.2.7. The low version.
But there are ~/anaconda3/lib/zlib_1.2.11 exists! That's why code worked well when I run this code in Spyder.
So I want to ask: Is there any way to use "~/anaconda3/lib/zlib_1.2.11" when I run python code on linux console?
Thank you.

Related

importing dlls with pythonnet in spyder

I have a python package that acts like a wrapper for a .dll written in C#. The binary is imported into python by the pythonnet package. Thus, the user can access the functionality of the so called cs_backend.dll conveniently from the python side. The import looks as follows:
import clr as __clr
import System as __System
__clr.AddReference(PATH_TO_CS_BACKEND + "\\cs_backend")
import cs_backend as __csb # exception thrown here
However, it seems that python can't import the .dll as I get a ModuleNotFoundError: No module named 'cs_backend'.
The odd thing is that this error only occures when running the code from Spyder. Executing exactly the same code from Visual Studio Code works perfectly fine.
Do you have any idea what the problem could be?
system specifications
os: windows 10
.net framework v4.5.1
python 3.8.5
spyder 4.2.1
Edit:
I have found a github issue on the pythonnet repository that describes a similar (although not quite the same) problem. However, since it has been open for about 3 years, it seems that there is little to no progress on that.
Edit 2:
There is a similar question here on stack overflow. The solution was to install a newer .NET Framework. This is not my problem since with any IDE other than Spyder the code works just fine. Thus, I guess that this is mainly a Spyder issue.
Currently, it seems that there is neither a solution nor an effort to resolve this problem.
It looks like the problem is caused by the IPython console integrated in Spyder.
A simple workaround is to execute the python script from the system console.
In Spyder this can be done by going to Run - Configuration per file - Execute in external system console.
With the new configuration it is at least possible to run the script.

Where can I find pre-installed packages that comes with Python IDLE?

I'm more specifically wanting to know whether sqlite3 and json comes with python IDLE or do I have to install them separately to use them inside IDLE, If so can anyone link me to those installing procedures of sqlite3 and json on Python IDLE?
I also want to know where I can find the list of other pre-installed packages that comes with basic Python IDLE (i.e. Python 2.7.14) . I am a Beginner and it would be really helpful.
Thank you.
To get a list of your packages, from your terminal, launch python :
python
Then
help("modules")
Another solution, if you want to check if json or sqlite3 are installed, start Python from your terminal :
python
Then import sqlite3 and json:
import json
import sqlite3
You can check theirs version with :
>>> json.__version__
'2.0.9'
>>> sqlite3.version
'2.6.0'
IDLE is part of the CPython standard library and is usually installed when tkinter (and turtle) are. It provides an optional alternate interface for running your code with a particular python binary. When you run code through IDLE, it is run by the python binary that is running IDLE. So the same modules are available whether you run code through the terminal interface or through IDLE. There is no separate installation.

Include opencv shared object in a Python project

I am trying to build the Python project openface, the project includes cv2 though I have a strong feeling this problem has nothing to do with openface and cv2 and more with me not understanding the Python development environment enough.
I am running on Mac OSX with El-Capitan, and am using Intellij but I have also tried PyCharm, which also comes from Jetbrains.
The issue is:
I have successfully compiled and installed cv2 on my machine and it is located at: /usr/local/lib/python2.7/site-packages/cv2.so
Meaning it is a shared object, but from my understanding it should still work.
I've added this so file to the Python SDK and installed it (at least I think I have).
This is a screenshot from Intellij:
And this is a screenshot from PyCharm:
And, yet, after I apply the changes:
import cv2
Is still not recognised in both Intellij and PyCharm.
How can I add this shared object to my Python project?
Many thanks in advance

An UCS2-UCS4 incompatibility import failure of a Cythnized pure-Python module

I'm running into a cython-unicode problem which I hope you can help me with -
I'm trying to compile with cython a python module which works alot with unicode objects.
I'm working on Ubuntu 12.04 32bit, (on a VM on a Win7 64bit host if it has any importance), I'm using Py2.5.4 (can't change that) which I've installed side-by-side with the provided Py2.7.3 (and soft-linked /usr/bin/python to /usr/bin/python2.5), and Cython 19.02 (current one). I'm compiling with no special flags.
Now, as compiling goes seemingly OK, when I open a Py (same 2.5.4) and try to import the resulting. SO file, I get a PyUnicodeUCS2 type error. That is supposed to mean, as I understand, that the SO was compiled on a python configured with UCS4, and imported to python configured with UCS2. But It's the same python I compiled on and imported to.
for compilation I use $ python setup.py bild_ext --inplace where setup.py uses distutlis.extension.Extension and Cython.Distutile.build_ext .
Can someone enlighten me with what's going on and what I can do with it?
I'll be happy to provide more details if I wasn't clear enough.
Thanks a lot..

Is it possible to write a windows service using Python?

Python has a win32service package that seems to allow windows service creation. I have carefully checked available google examples, for example this one:
Is it possible to run a Python script as a service in Windows? If possible, how?
I have placed code into ~/Documents/test.py and executed following under elevated command prompt:
> python test.py install
> python test.py debug
Unfortunately, every example i tried fails with error:
Debugging service TestService - press Ctrl+C to stop.
Error 0xC0000005 - Python could find the service class in the module
AttributeError: 'module' object has no attribute 'AppServerSvc'
(null): (null)
I have tested it with latest version of ActivePython (2.7.2.5 32-bit) on Windows 7 64-bit and Windows 8 64-bit. Of course, if service is started maually via service manager, it will not start either.
Am i doing something wrong or Python is not intended to be used for service creation on modern operating systems? Maybe i need a specific version of windows/python/pywin32? Of course, i can manually test all combinations starting from windows XP but it will take lots of time :(. Maybe someone already has experience with Python and windows services and can hint me what i'm doing wrong?
update
Tested on Windows XP 32-bit virtual macine (same code, same activepython distribution) - same error.
It appears that there is a bug in the ActiveState build for PyWin32. Installing ActiveState python 2.7.2.5 and running the linked sample code above, I get the same error that you are reporting.
But if I download Python 2.7.3 (2.7.2.5 does not seem to be available for download) and add PyWin32 build 214 (ActiveState seems to be using the 214 version of PyWin32). Then everything seems to work just fine. I also tried the latest build of PyWin32 (218) and it also worked correctly.
So I guess you can try reporting the problem to ActiveState (I don't have a support contract with them) and unless you have a requirement for using ActiveState, you can just switch to the standard Python builds.
I have been using services with the standard Python builds for years running on everything from Windows 2000 up to Server 2008 and Windows 7 with no problems. So I have good reason to believe that it will work for you also.
If you want to work with ActiveState to get the problem fixed, then the bug appears to be in their build of PythonService.cpp in the LoadPythonServiceInstance function. I looked at the registry entries that were created and they look fine, it is the PythonService.exe that is failing at loading your class. Based on the error message it appears to have loaded the module correctly and is just having trouble finding the class.

Categories

Resources