Download python from command prompt on windows - python

I am connected to a machine running Windows 8 from my linux machine using OpenSSH. I need to download python3 on the Windows machine but I only have access to the command prompt, not PowerShell. I also have sftp set up, but all the python downloads are installers which don't work through the command prompt. Does anybody know what I can do?

You can download using the curl program, if it's installed on your windows machine. Something like:
curl https://www.python.org/ftp/python/3.8.3/python-3.8.3-amd64.exe -o python_install.exe
(or look for the Python version you want at https://www.python.org/downloads/windows/)
Then, you can run:
python_install.exe /quiet
There are also zip file packages you can download from the URL above.
Note that a quiet install may not change your system's PATH, so you may need to locate the directory in which Python was installed, and call the program from there.

Related

How to find location of an executable?

I seem to have a "rogue" copy of python.exe on my Windows 11 machine. When I use it to create a virtual environment with the command "python -m venv venv", it produces an environment in which pip always fails. I have uninstalled Python from the add/remove probrams menu but will when I open a command prompt or a power shell and give the command Python, it responds cheerfully with Python 3.10.5 (main) [GCC 12.1..."
I can't use pip in any virtual environment
How can I determine where it is finding Python? How can I override it with a good Python?
In the Windows Powershell you can use the Get-Command command to find where a specific executable is being ran from. In CMD you can use where.
If you want to use a Python runtime that you have recently installed, and you know where it is located, I would just add that location to my PATH towards the top of the list so that when you run python in your terminal, you get that python.

WSL VSCode call Windows Python Executable

Context: Running python in VSCode on Windows
Default Terminal is Bash (via WSL)
Using WSL - Debian
Python 3 installed on Windows, not on WSL
I want Bash to call my Windows Python Executable when I run my python files. I am only using WSL so I can replace cmd/powershell with bash. I do not want to install anything on WSL, I want to use existing programs on Windows (in this case Python).
However when I try to run my Python file (Clicking 'play' button) I get the error:
-bash: C:/Users/Connor/AppData/Local/Programs/Python/Python310/python.exe: No such file or directory
I believe this can be solved by replacing C: with \mnt\c
How can I achieve this?
I had a same problem as yours. I solved this by following steps.
Open the VSCode
On your left-down side, you can see the the icon that I pointed enter image description here (the name in here is "Open a Remote Window")
Next you can see above the "Reopen Folder in WSL" enter image description here and clicked
Then you can run python with wsl and no more directory errors

Python is not installing on Windows 10

I tried to install Python to Windows 10, with the PATH installation included. However, when I click to enter in the Python application, it just appears the setup. I need to access the Python terminal.
Here is the setup
Make sure you are not accidentally opening the Python installation executable. Check again that the Python path is installed properly and try running the command "py" or "python" in the Command Prompt to see if it starts. If it doesn't start and Python is installed on your computer, manually add Python's install location to your PATH.

python27 and python3 are not not recognized as an internal or external command, operable program or batch file [duplicate]

I am using Python 3.5.2 version on Windows 7 and tried using python3 app.py. I am getting this error message:
'python3' is not recognized as an internal or external command,
operable program or batch file.
Is there any specific cause about why the python3 command is not working?
I also verified that the PATH is added to environment variables.
There is no python3.exe file, that is why it fails.
Try:
py
instead.
py is just a launcher for python.exe. If you have more than one python versions installed on your machine (2.x, 3.x) you can specify what version of python to launch by
py -2 or
py -3
You can also try this:
Go to the path where Python is installed in your system. For me it was something like C:\Users\\Local Settings\Application Data\Programs\Python\Python37
In this folder, you'll find a python executable. Just create a duplicate and rename it to python3. Works every time.
Python3.exe is not defined in windows
Specify the path for required version of python when you need to used it by creating virtual environment for your project
Python 3
virtualenv --python=C:\PATH_TO_PYTHON\python.exe environment
Python2
virtualenv --python=C:\PATH_TO_PYTHON\python.exe environment
then activate the environment using
.\environment\Scripts\activate.ps1
Yes, I think for Windows users you need to change all the python3 calls to python to solve your original error. This change will run the Python version set in your current environment. If you need to keep this call as it is (aka python3) because you are working in cross-platform or for any other reason, then a work around is to create a soft link. To create it, go to the folder that contains the Python executable and create the link. For example, this worked in my case in Windows 10 using mklink:
cd C:\Python3
mklink python3.exe python.exe
Use a (soft) symbolic link in Linux:
cd /usr/bin/python3
ln -s python.exe python3.exe
In my case I have a git hook on commit, specified by admin. So it was not very convenient for me to change the script (with python3 calls).
And the simplest workaround was just to copy python.exe to python3.exe.
Now I could launch both python and python3.
If python2 is not installed on your computer, you can try with just python instead of python3
For Python 27
virtualenv -p C:\Python27\python.exe django_concurrent_env
For Pyton36
virtualenv -p C:\Python36\python.exe django_concurrent_env
Enter the command to start up the server in that directory:
py -3.7 -m http.server
I had a related issue after installing windows 11, where python3 in cmd would open the windows store. I was able to sort it out between this post and this other one. In short, I reinstalled python and made sure to add it to PATH. Then, in settings, Apps > Apps & Features > App Execution aliases. Here, all I had to do was make sure that every single python .exe (including idle and pip) were turned off EXCEPT FOR the python3.exe alias. Now it works like a charm.
FWIW:
The root of this issue is not with you or with python. Apparently, Microsoft wanted to make installing python easier for young kiddos getting interested in coding, so they automatically add an executable to PATH. For those of us that already have this executable, it can cause these issues.
Found out instead press the play button the top right and it should work in visual studios:
Do not disable according to first answer
Saying python3 in the command will not work by default.
After figuring out the problem with the modules (Solution): https://youtu.be/paRXeLurjE4
Summary:
To import python modules in case of problem to import modules:
Hover over python in search:
Click open in folder
Hover over and right click
click properties
copy everything in path before \python.exe
close those windows
For cmd (administrator):
cd --path that was copied--
then python -m pip install --upgrade pip
cd Scripts
pip install "Name of Package" such as pip install --module (package) --
Im on win10 and have 3.7, 3.8 and 3.10 installed.
For me "python" launches version 3.10 and does not accept commands (like -3.7), "py" launches newest version but does accept commands, and "python3" does nothing.
Uninstalled 3.10 and "python" now does nothing, and "py" launches 3.8.
I am unable to add a comment, but the mlink option presented in this answer above https://stackoverflow.com/a/55229666/8441472 by #Stanislav preserves cross-platform shebangs at the top of scripts (#!/usr/bin/env python3) and launches the right python.
(Even if you install python from python.org, Windows will direct you to the app marketplace nowadays if you type python3 on the command line. If you type python on the same cli it will launch the python.org version repl. It leads to scripts that generate no output, but more likely silently failed completely. I don't know ho common this is but have experienced it on a couple of different devices)
If you have this at the top of your script to ensure you launch python3 and don't feel like editing everything you own, it is not a bad approach at all... lol.

Getting gcloud to work in Cygwin Windows

I am fairly new to programming. I have started app development on google app engine. I am trying to get the Google Cloud SDK to work with Cygwin 32 on Windows. I first ran the curl command to download the Google SDK files. Then I ran the install.py script and installed the SDK, however when calling gcloud in cygwin I receive this message:
Ammar Husain#Ammar-Computer:~
$ gcloud
/cygdrive/c/Users/Ammar Husain/google-cloud-sdk/bin/gcloud: line 102: C:\Python27: command not found
I have looked everywhere for a solution and have not been able to find one. I examined the gcloud file in the program files and it seems that there may be a problem with the Python Root Directory but I'm not sure. It may also be my Environment Variables.
Someone help?
I was having the same problem with Python not understanding the cygwin path. Instead of changing the gcloud script I created a C:/cygdrive folder. Then, I opened a windows command prompt and cded to the new folder. There, I ran mklink /D c C:\.
This created a link to the C: drive in such a way that Python understands /cygdrive/c/….
First: Cygwin 32? Do you have a 32bit machine? Otherwise the 64bit Version will be the better choice!
Please have a look here, if you DIDN'T install python via cygwin: Using python on windows
If you DID install it via cygwin: Set up python on windows
You might also have a look here: Set the pythonpath on cygwin
In all cases you have to add the python-directory to the PATH-Variable in Windows AND cygwin:
set PYTHONPATH=%PYTHONPATH%;C:\Path-to-python
echo "PATH=\$PATH:/cygdrive/c/Path-to-python" >> .bash_profile
After installing python 3.8 in my cygwin (with cygwin setup-x86_64.exe), I've used the versioned archive for Linux from
https://cloud.google.com/sdk/docs/downloads-versioned-archives
Then, I installed it in my cygwin home directory with this steps:
$ tar -xvf google-cloud-sdk-xxx.x.x-linux-x86_64.tar.gz
$ ./google-cloud-sdk/install.sh
$ source ~/.bashrc //
It worked for me

Categories