Sublime3 - cannot find file specified when executing python script in Windows - windows-10

I am trying to setup Sublime3 on Windows 10 Enterprise edition to execute a python script using Tools>Build.
Its a simple hello_world.py script.
Here's my output:
[WinError 2] The system cannot find the file specified
[cmd: ['python3', '-u', 'C:\\Users\\PBC9390\\Desktop\\python_work\\hello_world.py']]
[dir: C:\Users\PBC9390\Desktop\python_work]
[path: C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files\Python37\Scripts\;C:\Program Files\Python37\;C:\Program Files\Git\bin;C:\Program Files\Git\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\IBM\EHLLAPI\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\1E\NomadBranch\;C:\Program Files (x86)\Common Files\Hitachi ID\;C:\Program Files\Common Files\Hitachi ID\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files\PuTTY\;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Amazon\AWSCLI\bin\;;C:\hashiCorp\Terraform;C:\Program Files (x86)\Webex\Webex\Applications;C:\HashiCorp\Vagrant\bin;C:\Users\PBC9390\AppData\Local\Microsoft\WindowsApps;C:\Users\PBC9390\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin]
Here's my Python3.sublime-build file:
{
"cmd": ["python3", "-u", "$file"],
}
Is this the problem? I'm not sure how its being converted with double backslash "\":
'C:\\Users\\PBC9390\\Desktop\\python_work\\hello_world.py'

Related

Visual Studios - Nmap not found in Path, Creating Basic port scanner Python310

Firstly, I am following the tutorial at FreecodeCamp (https://www.freecodecamp.org/learn/information-security/python-for-penetration-testing/developing-an-nmap-scanner-part-1) - I may discontinue as there is so much ambiguity and little things wrong.. I honestly just want to follow a tutorial and have it work with what is done in the tutorial. X.X
import nmap
scanner = nmap.PortScanner()
print("Welcome, this is a simple Nmap automation tool.")
print("-----------------------------------------------")
ip_addr = input("Please Enter the IP you want to scan.")
print("The IP you entered is: ", ip_addr)
#Sanitize input
type(ip_addr)
c:\Users\WaffWaffles\Desktop\Python Projects>py scanner.py
Traceback (most recent call last):
File "c:\Users\WaffWaffles\Desktop\Python Projects\scanner.py", line 4, in
scanner = nmap.PortScanner()
File "C:\Users\WaffWaffles\AppData\Local\Programs\Python\Python310\lib\site-packages\nmap\nmap.py", line 136, in init
raise PortScannerError(
nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\metasploit-framework\bin\;C:\Users\WaffWaffles\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\WaffWaffles\AppData\Local\Programs\Python\Python310\;"C:\Program Files (x86)\Nmap";C:\Users\WaffWaffles\AppData\Local\Programs\Microsoft VS Code\bin'
When I add
#!\C:\Users\WaffWaffles\AppData\Local\Programs\Python\Python310
to the top I get
c:\Users\WaffWaffles\Desktop\Python Projects>py scanner.py
Unable to create process using '\C:\Users\WaffWaffles\AppData\Local\Programs\Python\Python310\ scanner.py'
I have python-nmap installed through py -m install python-nmap too.

RuntimeError: Failed to init API, possibly an invalid tessdata path:<>

I am using windows os. Want to detect the text from an image with fontAttributes by tesserocr. But when I am running the python code, I am getting this error -
RuntimeError: Failed to init API, possibly an invalid tessdata path: C:\Program Files (x86)\Tesseract-OCR\tessdata/
i) I have installed -
tesseract-ocr-w32-setup-v5.0.0-alpha.20190623.exe
//(though my system is 64 bit)
ii) Added to path variable (both system and user path) -
C:\Program Files (x86)\Tesseract-OCR
C:\Program Files (x86)\Tesseract-OCR\tessdata
iii) Created new system path variable - TESSDATA_PREFIX and linked path of
tessdata folder, like -
TESSDATA_PREFIX - C:\Program Files (x86)\Tesseract-OCR\tessdata
import pytesseract
import locale
locale.setlocale(locale.LC_ALL, 'C')
from tesserocr import PyTessBaseAPI, RIL, iterate_level,OEM
with PyTessBaseAPI(oem=OEM.TESSERACT_ONLY,lang='bask') as api:
api.SetImageFile('sugar.png')
api.Recognize()
ri = api.GetIterator()
level = RIL.WORD
for r in iterate_level(ri, level):
attrs = r.WordFontAttributes()
symbol = r.GetUTF8Text(level)
print(symbol,attrs)
with PyTessBaseAPI(oem=OEM.TESSERACT_ONLY,lang='bask') as api:
File "tesserocr.pyx", line 1168, in tesserocr._tesserocr.PyTessBaseAPI.__cinit
__
File "tesserocr.pyx", line 1181, in tesserocr._tesserocr.PyTessBaseAPI._init_a
pi
RuntimeError: Failed to init API, possibly an invalid tessdata path: C:\Program
Files (x86)\Tesseract-OCR\tessdata/
Probably you don't have the .traineddata files in your system. you have to copy it from
C:\Program Files\Tesseract-OCR\tessdata
and paste all the data files to your directory , I'd suggest create a virtual environment ans then use it

SublimeText3 Build System for Pandoc

I am trying to create a build system to run pandoc and save as pdf using pdflatex:
{
"selector": "text.html.markdown",
"working_dir": "$file_path",
"cmd": [
"C:\\Users\\Administrator\\AppData\\Local\\Pandoc",
"-f", "markdown",
"-t", "latex",
"--pdf-engine=pdflatex",
"-s",
"-o",
"C:\\Users\\Administrator\\Desktop\\output.pdf",
"$file"
]
}
I get an "Access is denied" error and cannot figure out what's wrong:
[WinError 5] Access is denied
[cmd: ['C:\\Users\\Administrator\\AppData\\Local\\Pandoc', '-f', 'markdown', '-t', 'latex', '--pdf-engine=pdflatex', '-s', '-o', 'C:\\Users\\Administrator\\Desktop\\output.pdf', 'C:\\Users\\Administrator\\Desktop\\CP10328R-TEST.md']]
[dir: C:\Users\Administrator\Desktop]
I have confirmed that I can write a file to the desktop without any issues, so the "access is denied" error must be related to something other than the output file. I have also tested using pdflatex as the engine and I can create PDFs from LaTex without any errors using an install of Texworks on the same machine, so the issue cannot be with LaTex. Finally, I have confirmed the path to pandoc is correct.

SublimeHaskell cannot build

I am using Sublime Text 3 on mac el capitan, and when I try to build a haskell file, I receive the following error message:
[Errno 2] No such file or directory: 'runhaskell'
[cmd: ['runhaskell', 'path_to_my_file']]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]
The SublimeHaskell User settings is as follows:
{
"add_to_PATH":
[
"/Users/durand/Library/Haskell/bin/",
"/usr/local/bin/"
],
"enable_ghc_mod": false,
"enable_hdevtools": false,
"enable_hsdev": false,
}
I don't know why the path in error message does not include the path I specified in the User setting, and am not sure if this causes the problem. But using SublimeHaskellREPL: ghci currentfile works fine.
Also, the runhaskell is located in /usr/local/bin/ but for some reason I cannot make this directory seen by SublimeHaskell. In addition, both the echo "$PATH" and /etc/paths tell me that the /usr/local/bin/ is in the path variable, which confuses me even further.
Any help is appreciated. Thanks in advance.

Strong Named satellite assemblies using ResGen & AL with multiple resx / resources files

For whatever reason, when compiling multiple .resources files into a single satellite assembly (.dll) the resources will not show. Compiling a single resource will work. Here are the steps I used...
We have a project called "Report Viewer". This project is signed using a key, MySnKey.snk via Properties > Signing > Sign the assembly , choose a strong name key file: MySnKey.snk.
All forms have been updated to Localizable = True
We processed all the resx files into German de-DE. There are only two resx: MainForm.resx (project root directory) and Resources.resx (Properties directory).
I have a folder with MainForm.de-DE.resx and Resources.de-DE.resx which are the translated versions of these files.
Using resgen,
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" /compile Resources.de-DE.resx ReportViewer.Resources.de-DE.resources
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" /compile MainForm.de-DE.resx ReportViewer.MainForm.de-DE.resources
This creates the appropriate .resources files. Now to link, I use AL.exe:
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL" /t:lib /embed:ReportViewer.MainForm.de-DE.resources,ReportViewer.Resources.de-DE.resources /culture:de-DE /out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk
This creates a ReportViewer.resources.dll file. If I place it into the appropriate sub folder de-DE>ReportViewer.resources.dll, no luck. In Program.cs, before Run is called, I have
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");
IF, I only include the MainForm like
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL" /t:lib /embed:ReportViewer.MainForm.de-DE.resources /culture:de-DE /out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk
The appropriate resources are displayed.
This is quite confusing to me. If I add the .resx files to the solution, and compile, the output dll works correctly, but we are trying to avoid having to bring these satellite translations into the solution.
No errors are generated and the files are created so I'm lost as to what I'm not doing.
Any help is greatly appreciated. I compared the differences between the output dll when adding the files to the solution to the output file when running AL.exe and they both contain all the translations.
EDIT to include solution since I can't answer the question
Apparently I got confused with the embed option and it's usage. To properly use the AL.exe utility, I had to use:
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" Resources.de-DE.resx ReportViewer.Properties.Resources.de-DE.resources
Notice above that the Properties namespace is added. I had not done that before.
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx ReportViewer.MainForm.de-DE.resources
Notice that no Properties namespace is added since MainForm is Simply in the ReportViewer namespace.
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL"
/t:lib
/embed:ReportViewer.Properties.Resources.de-DE.resources
/embed:ReportViewer.MainForm.de-DE.resources
/culture:de-DE /out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk
Notice that there are multiple /embed items in this line. I was using the comma, which renames the internals and is not what I wanted. Providing a space between the files gives a (seemingly) unrelated error. See http://ondotnet.com/pub/a/dotnet/2002/10/14/local2.htm?page=2 for a great article.
For completeness, another way of writing this script would be
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" Resources.de-DE.resx
notice that no renaming is done here, the output is simply Resources.de-DE.resources
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ResGen" MainForm.de-DE.resx
notice that no renaming is done here, the output is simply MainForm.de-DE.resources
> "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\AL" /t:lib
/embed:Resources.de-DE.resources,ReportViewer.Properties.Resources.de-DE.resources
/embed:MainForm.de-DE.resources,ReportViewer.MainForm.de-DE.resources
/culture:de-DE
/out:ReportViewer.resources.dll /template:../../../Output/ReportViewer/bin/Debug/ReportViewer.exe /keyfile:../MySnKey.snk
Notice that the renaming is done following the comma in the embed option. The first argument is the file name (the .resources file) and after the comma is the fully qualified name (namespace.class.xx-XX.resources).
Answered in the post before I knew I could answer it here.

Resources