I tried many times installing, "protoc-3.2.0-windows-x86_64.exe", but it doesn't get installed. When I double-click on it, there would be no screen displayed. I tried opening it through command line interface. I got a message as "Missing Input File".
Protoc Installation Error on Command Prompt
What is that missing input file? What should I do now? Please respond to my problem at the earliest!
protoc-3.2.0-windows-x86_64.exe is the Protocol Compiler. It is not an installer. This is the program itself.
This program is designed to run on the command line. It takes a .proto file as input (which you specify on the command line) and it outputs code in a variety of languages. It says "Missing input file" because you didn't specify a .proto file.
To "install" it, copy the .exe file to wherever you want to run it from. You may want to rename it to protoc.exe, and place it somewhere in your PATH, so that the command you have to type becomes just protoc.
The binary has to be placed in the path specified by Command Prompt, when opened under Admin mode. For me, under Admin mode, it was "C:/Windows/System32".
Related
Here I'm using python 3.9.0
pyinstaller : The term 'pyinstaller' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
So pyinstaller isn't on your path
According to WikiPedia A path is a string of characters used to uniquely identify a location in a directory structure. It is composed by following the directory tree hierarchy in which components, separated by a delimiting character, represent each directory.
Checkout this Question from Stackoverflow it will help you
The problem here is that you are not in the shell but in Microsoft PowerShell. That's something completely different. Even if it looks a little like a command shell.
Exit the PowerShell and open the command shell by pressing "Windows Logo"+R, enter cmd and hit OK. Then, you can execute pyinstaller.
Alternatively (and sometimes much easier), you can create a Batch file to execute the pyinstaller command line with all necessary options. Just create an empty text file, write the command in it, write pause on the last line and store it with the extension .BAT. You can then double-click it to execute the command. (pause is necessary to keep the terminal open until you have read all messages, warnings and errors)
I resolved it by this process.
Run this command in the respective path where you got an error.
pip uninstall pyinstaller
go to main python folder C:\Users\USER NAME\AppData\Roaming\Python
and open powershell window in the python path and Now run this command.
pip install pyinstaller
Let's say I have a python file named myfile.py in a certain directory.
How do I just call the python file directly without invoking python.
myfile.py
and not
python myfile.py
Edit:
To be more precise.
just typing the filename in the command line will not work.
Typing start program.py however should work.
Windows normally has information telling it which program is the default program for a given suffix.
Concerning #go2nirvan's comment: Though windows is not an oracle, it can have information for each file suffix to know what's the related default application.
Even many linux desktop application associate a default application to certain mime types.
If you click on .xls (depending on what is installed) either Excel, or OpenOfficeCalc or LibreOffice will be opened)
Windows associates file suffixes to file types and file types to applications, that are supposed to start it.
If you open a CMD window and you type
assoc .py
You should get an output similar to: (I don't have a windows machine nearby, so can't tell you the exact output)
.py=Python.File
Then type
ftype Python.File or whatever the previous command gave you and you should see which executable shall be used.
This should be something like
c:\System32\py.exe
which is a wrapper program, calling the real python executable according to some rules
If this doesn't work, then please tell which version of python you installed and how you installed it (for all users, for current user, ...)
From command line you have to call (If I recall correctly)
start test.py and it will execute the file with the associated executable
Windows
Set up Python on Windows to not type "python" in cmd
Linux
https://superuser.com/questions/828737/run-python-scripts-without-explicitly-invoking-python
I just switch laptops and everything seems to be normal except this. When I open CMD and try to run a file like py filename.py
it comes up with an error
C:\Users\john\AppData\Local\Programs\Python\Python37\python.exe: can't open file 'filename.py': [Errno 2] No such file or directory
It defaults to the python.exe file. It does it for every file that I try to run as well. I am in the correct directory (the directory where the actual file is in) but it keeps defaulting to that error. I am running windows 10 with python 3.7.3.
You may have to change the default directory where your terminal looks for the python.exe file and its packages. You must change both. One variable points to the python[version] folder and the other points to the python[version]\scripts folder.
This page shows you how to redirect your terminal in windows:
https://superuser.com/questions/1399544/how-to-change-default-python-executable-on-windows-10/1399546
Another tip is that you must change these two identical directories for both the "user variables" and the "system variables" listed in the section below it. I believe the Python installation has probs with this, especially if it's a reinstall or a failed update. And on Windows in general.
Best,
[Submitted to superuser two days ago, but nobody could answer it, so reposting here.]
Working on the basis of this post (and this follow-up post), I've tried adding a python script (which I've added to the path and so on, so that I can run it from the command line everywhere in the system) to the context menu, like this:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\get_abs]
#="&Get Abstracts"
"Icon"="%SystemRoot%\\System32\\shell32.dll,71"
[HKEY_CLASSES_ROOT\Directory\Background\shell\get_abs\command]
#="C:\\cmdtools\\get_abs.py"
However, I get a strange error message when I try to run it.
To be clear, I have successfully run this script from the command line (using powershell, in case it matters) in the folder in which I'm trying to run it from the context menu.
Python scripts aren't natively executable by Windows; it's complaining that you didn't specify an .exe file. That's easy though, you just specify python.exe. Follow that up with the path to your script and then a %1 -- this is a placeholder for the path to the clicked file. To allow your command to work with paths with spaces in them, surround the %1 with quote marks. Putting it all together, we get:
C:\path\to\python.exe C:\path\to\your\script.py "%1"
BTW, a handy utility for managing context menus is Fast Explorer.
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