Trouble installing & starting Python from command line in Windows 7 - python

I'm installing Python for use with SQLMap. I've downloaded and ran the Python 2.7.2 MSI installer, and restarted my computer. According to everything I've read, I should be able to just call python and SQLMap from the DOS command line using python sqlmap.py, but the command line doesnt seem to recognize the python - I get a 'python' is not recognized as an internal or external command,
operable program or batch file. error.
Do I need to add Python to my path variable? If so, how? Everything I've read says it should work out of the box...

Yes you should add it to your path. Does running C:\Python27\python.exe sqlmap.py work?
See for instance https://superuser.com/questions/143119/how-to-add-python-to-the-windows-path

Related

How to run a python library without installing it

I have to run a shell script on a Centos Linux machine that calls a python file. Inside the python file, there is the following code snippet:
from lib.rclone import Rclone
rclone = Rclone()
if shutil.which("rclone") == None:
print("Rclone executable is missing, install it")`
The problem is that I am not supposed to install any code (including rclone) on the machine. Therefore, whenever I call the shell script, it ends up with the error message. I don't know how can I successfully run it?
The program you are running requires rclone. Since you cannot install it, you cannot run it. Simple as that.
You can try to release the script as a .exe file.
By using pyinstaller (https://pyinstaller.org/) you don't have to install any libs or py package on the target machine, you can even choose to release it as a single executable.

Why does python --version return nothing in the command prompt

I recently installed Python 3.7.9 for a class I am taking. I am able to run python code both through the windows command prompt and Visual Studio 2019. I was making sure everything was set up correctly. However, when i run the command python --version, it just enters a blank line. IS there something im supposed to do after installing python to set up my Command Prompt?
VS code pulls from the specified file path for each python version, so it will work regardless of if python has been added to your PATH.
Does it give you an error when you just type python into your CMD (not inside vs code)?
If it does then you need to add python to your PATH, details for this can be found here:How to add a folder to `Path` environment variable in Windows 10 (with screenshots)
and the folder paths you need are:
%USERPROFILE%\AppData\Local\Programs\Python\Python37\Scripts\
%USERPROFILE%\AppData\Local\Programs\Python\Python37\

How to make Python 3 my default Python at command prompt?

I have uninstalled Python 2.7 and installed Python 3. But, when I type Python on my command prompt I get this :
"Enthought Canopy Python 2.7.9 ........."
How can I run Python 3 from command line or how can I make it default on my computer? I asked Enthought Canopy help and I was told that I can "have Canopy be your default Python only in a "Canopy Command Prompt". Not sure what it means.
edit : Thanks everyone. As suggested, I had to uninstall everything and install Python again.
Windows selects which executable will be run by searching the directories in-order from the PATH environment variable (source):
The shell now searches each directory specified by the PATH
environment variable, in the order listed, for an executable file
matching the command name. If a match is found, the external command
(the executable file) executes. If no match is found, the shell
reports an error and command processing completes.
You can modify PATH to put your Python 3.4 directory (typically C:\Python43) before your Python 2.7 directory. From Windows 7 and up, you can use where python to confirm which python will be run (first line of the output).
After editing each path and creating a new variable for each python version, be sure to rename the python.exe to a unique one. i.e. "python3x" . then you can call it in the command line as "python3x". I am assuming that the original python installed (2X) retains the python.exe of which when you call "python" in the command line, it will show the 2x version
You can copy python.exe to python3.exe.
If you are using Anaconda, then you will find it in the sub directory of your environment, for intance, c:\Anaconda\envs\myenvironment.

Python is not recognized after cd

I am using Windows 8 64-bit. I installed Python, and see that Windows Path is appended by the two paths : C:\Python27\Scripts; C:\Python27;
So when I run cmd and type python I get the error
'python' is not recognized as an internal or external command,
operable program or batch file.
I also tried py, same error.
I'm currently using the solution proposed here, so I'm typing
C:\Python27\python.exe manage.py runserver for example. But this is not what I want. How can I make it work with the command python?
Thanks in advance.
You should not have a space after the semicolon in the PATH value.

Python: making QRcodes in Windows

I'm new to Python. I'm trying to run this script (gencards.py) in Windows, but he says I need to run "the qrencode command". I assume that means this library, or the more likely the windows port.
In the python script, he uses qrencode as so:
os.system("qrencode -o .tempqr.png -s 30 -m 0 -l H " + serial)
I've installed the windows library via the executable, I added qrcode.exe to PATH, and tried editing gencards.py to use "qrcode" or "qrcode.exe" but I always get
'qrcode' is not recognized as an intrnal or external command, operable program or batch file.
What am I doing wrong?
I'm using Python 2.7 on Windows7 x64.
the error message means that Windows does not know what to do with qrcode. Check if it's installed in your system, and if it's directory is included in your PATH environment variable
Try to break the problem down, by first checking if you can run the programm (btw, is it 'grencode' or 'grcode'?) using a command prompt. If you can't then check your PATH settings again. When you succeeded with the command prompt get back to your python script.

Categories