pydeps fails to generate dependency graph - python

I'm attempting to use the Python module pydeps (installed with mamba install pydeps) to analyze the dependencies in my project. However, when I run the command pydeps main.py (perhaps "main.py" is not the most informative script name ever), I get the following output:
<pydeps_folder>/pystdlib.py:17: UserWarning: stdlib_list does't support Python 3.10 yet, pydeps will use symbols from 3.9 for now.
warnings.warn(
ERROR: While opening '<working_directory>/main.svg': [Errno 2] No such file or directory: 'xdg-open' (can be caused by not finding the program to open this file)
When I then run the command firefox main.svg, I see a graph containing some of the files in my project, but not all of them, so it seems like pydeps succeeded partially. Do I need xdg-open for pydeps to work? Or is there any way I can make pydeps work by telling it to just generate the svg file and not try to open it?

Answer
xdg-open in this context is used to open the main.svg resulting file. It is a linux utility that opens a file or URL with a preferred/default application. (i.e jpg -> image viewer). In this case it tries to open main.svg with your preferred image/svg file viewer.
It sounds like it errors out when trying to open the final result main.svg, which is what you're doing by executing:
firefox main.svg
Therefore I don't think its a partial result of the dependencies.
References:
xdg-open docs: https://linux.die.net/man/1/xdg-open

Related

Pyinstaller - Python exe when run shows error "Failed to execute script pyi_rth_nltk"

I have developed a simple software in python with GUI. I'm actually working on Natural Language Processing and I've just put the whole NLP process in a GUI.
I tried to convert the whole project to a exe file in python using Pyinstaller. I successfully converted it to an exe file but when I run it , it shows an error message something like this
This is the image of my error
I have already solved it but by using another way of converting py to exe which is the cx_Freeze.
I had the same issue earlier today and finally got it to work using the following software versions:
Python 3.6.8, nltk 3.5 and a dev version of pyinstaller:
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
Additionally, I used scikit-learn version 0.21.1.
Few days back, I had the same problem while compressing to EXE. This Problem generally occurs when PyInstaller failes to find Libraries and Modules to import to the directory. But I overcame this problem and the wise solution yet tedious method to do is mentioned below,
Convert Python Scripts to EXE with console = True in the .spec file or to be simple, do not add --noconsole argument while converting using System Argmuents method.(execute GUI with CMD)
After successfully building the file, go to respective directory (dist folder) and open command prompt
Run the Exe file using Command Prompt.
Find the error message and rectify it correspondingly. For example, consider the following Error Message, vcomp140.dll is missing from \\sklearn\\libs directory.
At the end of this Error Message, you'll find Failed to load dynlib/dll , Therefore, find the file or program which is missing. Say, Here we've .libs\\vcomp140.dll
Find vcomp140.dll using window search bar in your C Drive.
Copy the specific file and paste in the directory(under "dist" folder) where the file is missing. Here, the directory is dist\\PyScriptToEXE\\sklearn\\.libs
MatplotlibDeprecationWarning:
The MATPLOTLIBDATA environment variable was deprecated in Matplotlib 3.1 and will be removed in 3.3.
exec(bytecode, module.__dict__)
Traceback (most recent call last):
...
...
...
py3.7.egg\PyInstaller\loader\pyiboot01_bootstrap.py", line 169, in __init__
__main__.PyInstallerImportError: Failed to load dynlib/dll 'C:\\Users\\MOHAMM~1\\AppData\\Local\\Temp\\_MEI38242\\sklearn\\.libs\\vcomp140.dll'. Most probably this dynlib/dll was not found when the application was frozen.
[13968] Failed to execute script try
Follow the steps again using CMD to eliminate each error.

"python.exe can't find '__main__' module in ..." Error when trying to run python script opencv_blink_detect.py in virtual environment,

Apologies if there's missing information. I'm using python for medical research and am trying to run a program to count the number of blinks via video footage.
https://github.com/skvrahul/blink_detect
The script is located here
My virtual environment is set up here:
Package install instructions were followed from here
Terminal open via Anaconda
Attempt to run via readme instructions
Attempt to direct terminal to look at file path
As you can see, the error message is
(opencv-env) C:\Users\wmj>python C:\Users\wmj\Documents\Python Scripts\Biometrics\blink_detect-master.py -p -sp.dat
C:\Users\wmj\AppData\Local\Continuum\anaconda3\envs\opencv-env\python.exe: can't find 'main' module in 'C:\Users\wmj\Documents\Python'
The contents of C:\Users\wmj\Documents\Python is just Anaconda3-2018.12-Windows-x86_64
I have searched online and most solutions to this problem seem to be either solved by modifying the .py file or doing something with Pycharm
What is the solution to this? I want to be able to run the script as a demonstration to my supervisor
Thank you,
WW
Try first to cd to the exact location of the package and then run exactly as written in the readme instructions.
Python has to get the full path of the script you're trying to execute and the script itself has to get the sp.dat file as an argument.

CNTK tutorial:"Hands-On Lab: Image recognition with Convolutional Networks, Batch Normalization, and Residual Nets" python problems

I am trying to follow this tutorial:
https://github.com/Microsoft/CNTK/wiki/Hands-On-Labs-Image-Recognition
I am now at the point where Frank is saying:” Please execute the following two Python scripts which you will also find in the working directory:
wget -rc http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
tar xvf www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
python CifarConverter.py cifar-10-batches-py
I am using windows 10.
I assume that wget is a Linux “thing”. I have downloaded the file from http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
To the path of the CifarConverter.py script as i can not run wget from cmd or cygwin.
Next I am trying to run the tar command but get an error” No such file or directory”
I changed the command to tar xvf cifar-10-python.tar.gz and executed it from Cygwin.(I just made a fresh installation of cygwin 2.6.0) This extracts the data.
Next I am running the python command:” python CifarConverter.py cifar-10-batches-py” (from cygwin)
But I am getting an error from line 48!
I have tried change the line to: print ("error") but is only getting a new error in
import cPickle as cp
ImportError: No module named 'cPickle'
What shall i do to run the python script?
You are using Python 3.+ version. Try it with Python 2.7, and it should be ok.
It may be easier to follow this tutorial using the Jupyter Noteboks found here:
https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_201A_CIFAR-10_DataLoader.ipynb
https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_201B_CIFAR-10_ImageHandsOn.ipynb
These are installed with the CNTK and is very easy to click through. Just make sure to run the CNTP34PY.BAT file to activate the Python environment first, set default directory to the Tutorials folder and start Jupyter Notebook by typing "Jupyter Notebook" from the command prompt.
Previous answer works, if you want to keep using Python 3, change cPickle to Pickle and it should work...
Specifically:
Open Convert-CifarConverter.py in a text editor.
Find and Replace cPickle with Pickle (Should be two instances.. one
at the top where you import it, then one where it's being used in the
code).
Where it's being used in the code, may need to change some import
arguments if the code still doesn't run.
For example, the encoding:
pickle.load(f, encoding='latin1')

python portable matplotlib.gif no such file or directory

So, I have Python Portable 2.7.5.1 on my USB (every option installed, including Matplotlib), and whenever I try to run a script with a Matplotlib code, I get this:
TclError: couldn't open "*path*\Portable Python 2.7.5.1\App\lib\site-
packages\matplotlib\mpl-data\images\matplotlib.gif": no such file or directory
The mentioned matplotlib.gif file is in the specified directory,
so I don't know what to do to make it work...

Python correctly finding and reading windows application event logs

so my ultimate goal is to use python to read a specific application's windows event log when triggered by a file update.
Here is my problem, python I believe does not have access to the event logs stored in C:\Windows\System32\winevt\Logs. Whenever I try to read the files I get the following error:
WindowsError: [Error 2] The system cannot find the file specified
I tried every form of escaping, string split/join and using quotes on the file path and I always get the same error. I even cheaply used the os.system('dir "C:\Windows\System32..."') command in the python command prompt to list directories higher in the path for the log to verify access and I receive similar errors up to the C:\Windows\System32 directory, that one will list just fine.
Example:
C:\Windows\System32\winevt\Logs - File not found
C:\Windows\System32\winevt - File not found
C:\Windows\System32 - Lists files
I know these directories exist. So from here I figured I could use a bash script to copy the event log into a temp folder for python to read. I wrote a real simple bash script containing:
xcopy /Y "C:\Windows\System32\winevt\Logs\XXXXXXX" c:\Temp
(XXXXXXX) being the name of the log I want to copy for the python script.
The bash script runs fine on its own but when called by my python script it fails, refuses to copy the file because it can't find it. I have even tried using py2exe to create an exe to then run in administrator mode. This failed too. With similar errors of the file not found. I'm not sure I understand the permissions python uses to call the script and why the bash script cannot copy the file even when it can do it in a normal command prompt.
Any suggestions or flaws you can point out in my logic would be great. I am very stuck.
You are using a 32bits python on a 64bit install of windows.
In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64
You can use os.listdir("c:\windows\sysnative\winevt\logs") as a workaround to read from the real system32 dir from a 32bit python interpretter runing on a 64bit windows...
Sources:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx
http://support.microsoft.com/kb/942589

Categories