UNZIP error python 3.5 - python-3.x

i am trying to update a script from 2.7 to 3.5 i keep getting an error with the following.
def _openScure(self, new_image):
return os.system("unzip "+new_image)
the issue is with unzip in python 3.5 what should i replace it with?
error says. 'unzip' is not recognized as an internal or external command.
i have tried the following.
import zipfile
with zipfile.ZipFile("name.zip", "r") as zip_ref:
zip_ref . extractall (".")
running win7 python 3.5 any ideas i would be most grateful.
So heres a link to the entire script i am trying to update to 3.5. The issue i am having is with line 17. Any thoughts?
https://github.com/agusmakmun/Some-Examples-of-Simple-Python-Script/blob/master/Stegano-Extract-and-Read-File-From-Image/script.py

Related

Problem when importing gurobi through httpd

I successfully configured gurobi on centos 7 and it works if I try gurobi_cl on a test.lp file where the test.lp file contains just one line:
Minimize
Now i try to import gurobi from a script that is launched from httpd an I get this error:
From gurobi import *
File"/usr/lib/python2.7/site-packages/gurobipy/init.py" line 1 in
From .gurobi import *
ImportError: libgurobi90.so: cannot open shared object file:
No such file or directory
I am using gurobi9.0.1 and python 3.7 and I don't know why gurobi is calling python 2.7 in the log below.
Could you please help me?
Thanks
Solved the problem. I had to add gurobi_pi.conf under old.so.conf containing the path to my gurobi folder
ldconfig

Python packaging with Pyinstaller

I am trying to package my python file using Pyinstaller. I follow the instructions from this link
https://datatofish.com/executable-pyinstaller/
but I get this error.
RecursionError: maximum recursion depth exceeded.
I tried to added the following line of code as it was suggested on few pages but so far no success.
**import sys
sys.setrecursionlimit(1500).**
Any help?
Just so you all know the error was caused by Anaconda environment. It is not compatible with Python 3.7 and Pyinstaller. As soon I as uninstall Anaconda and run the Pyinstaller function, everything was fine and I managed to create an exe file.

Issue with python import for mapr_streams_python

I'm playing with the MapR Sandbox and would like to import some data in MapR stream using python. But I'm having an importing issue and I dont know why. I followed instructions from MApR website (see reference at the end of this post) and looked everywhere for a clue, but know I don't really know what else I can do. I tried with python 2.7 and python 3.6.
File "producer.py", line 1, in <module>
from mapr_streams_python import Producer
ModuleNotFoundError: No module named 'mapr_streams_python'
I have installed it globally like doc is telling me to do, the file is located in /usr/lib64/python2.7/site-packages for python 2 /usr/lib64/python3.6/site-packages for python 3
Someone has an idea?
Thank you
References
https://mapr.com/docs/60/AdvancedInstallation/InstallingStreamsPYClient.html
https://mapr.com/docs/52/MapR_Streams/MapRStreamsPythonExample.html
I noticed that the folder for the module was incorrectly named in the folder that it was installed at. After getting to the directory with the modules (/usr/lib64/python3.6/site-packages), just run this command:
cp -R mapr_streams_python-0.11.0-py3.6.egg-info/ mapr_streams_python
You should then be able to import the package in python.

module 'psutil' has no attribute 'process_iter' in python 3.5

I am using python 3.5.2 on windows10 machine and having problems running a py script.
I am getting this error: 'psutil has no attribute process_iter' if either use psutil.process_iter() or psutil.process.get_list().
I have psutil 5.4.3 installed.
Downloaded and tried this file https://pypi.python.org/pypi/psutil.. no luck
Here is the code:
import psutil
def processcheck(seekitem):
for proc in psutil.process_iter():
#for proc in psutil.get_process_list():
if proc.name() == seekitem:
....
for process in machine_process:
processcheck(process)
Any idea how can you get around this?
It works in Linux though.
Thank you.
I had this problem when my script was named psutil.py
Just rename your file if you have the same issue.

string: syntax error on raspbian jelly, flawless on IDLE windows 8

My script (python 3.6) raises an error when executed on my RPI (Linux raspberrypi 4.9.59-v7+ #1047), but runs flawlessly when executed with IDLE, on a windows 8.1 PC.
Basically, I want to create a gzip archive from "data.json" file.
Here is a light version:
import time
import gzip
inputFile = "/path/to/data.json"
dataArchiveName = f"{inputFile}-{time.localtime().tm_mday}_{time.localtime().tm_mon}_{time.localtime().tm_year}.gz"
...
When I run the script, the following exception is raised:
File "dataManager2.py", line 96
dataArchiveName = f"{inputFile}-{time.localtime().tm_mday}_{time.localtime().tm_mon}_{time.localtime().tm_year}.gz"
^
SyntaxError: invalid syntax
I do not understand why... Any idea ?
Thank you in advance
f-strings were introduced in Python 3.6, since you are using Python 3.5 on you Raspberry Pi, you will have to either install Python 3.6 on it or use older way of formatting strings, this should work:
dataArchiveName = "%s-%s_%s_%s.gz" % (inputFile, time.localtime().tm_mday, time.localtime().tm_mon, time.localtime().tm_year)

Resources