I downloaded python 1.11 from the python website but whenever I try to launch "python" in command prompt it launches the windows store and tells me to install python.
I ran py -3 and it launches python 3.11 in the command prompt. Is this the only way to access python though why doesn't "python" work?
You need to add python to Windows PATH.
Try using windows search and search for Edit the system environment variables, and then click on Environment variables. You will see "User variables" and "System variables". Find PATH variable in both sections. If you cannot find it, Click "New...".
If you are editing existing PATH, add these 2 lines:
<Your python installation path>\Python311
<Your python installation path>\Python311\Scripts
E.g.:
C:\Users\<User>\AppData\Local\Programs\Python\Python311
C:\Users\<User>\AppData\Local\Programs\Python\Python311\Scripts
If you are creating new PATH variable, add the following line:
<Your python installation path>\Python311;<Your python installation path>\Python311\Scripts
E.g.:
C:\Users\<User>\AppData\Local\Programs\Python\Python311;C:\Users\<User>\AppData\Local\Programs\Python\Python311\Scripts
Save the variables and you can access python using python on terminals.
Note: On some windows, PATH is defined as Path.
Related
I'm learning python and use VS Code as the editor and when I try to run the .py file I get the following message ,
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
3 Ways to solve this :-
If Python is not installed,then install it from python.org
If its already installed then it might not have been added to path.
To add python to path, search for environment variables in search bar, then edit the path option and add the python installation directory location there.
OR you may just re-install python from python installer and tick the "add python to path" option
Plus I would not recommend using windows store version of python. Just use normal python installer from python.org
I trying to run a program in python 3 that uses numpy but it gives me the error ModuleNotFoundError: No module named 'numpy'. I am using Windows 10. I tried running pip install numpy and it says pip is not a recognized command
You need to add python to your environment variables
Computer -> System Properties (or Win+Break) -> Advanced System Settings
Click the Environment variables button (in the Advanced tab)
Edit PATH and append ;C:\Python27 to the end (if you need substitute your Python version)
Click OK. Note that changes to the PATH are only reflected in command prompts opened after the change took place.
If you are running python 3.6 you will need to add python to your environment path through command prompt
Windows allows environment variables to be configured permanently at both the User level and the System level, or temporarily in a command prompt.
To temporarily set environment variables, open Command Prompt and use the set command:
set PATH=C:\Program Files\Python 3.6;%PATH%
set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
These changes will apply to any further commands executed in that console and will be inherited by any applications started from the console.
To change System variables, you need non-restricted access to your machine (i.e. Administrator rights).
If you were to run python -v it should now work
This came directly from the python documents section 3.3.1
Now after you restart you should be able to access python through the command line. If you are running 2.7.9+ or 3.4+ pip will come prepackaged with python. However, if you are running an earlier version of python
Per https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip:
Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt:
python get-pip.py
You possibly need an administrator command prompt to do this. Follow Start a Command Prompt as an Administrator (Microsoft TechNet).
Thanks to How do I install pip on Windows?
Add "way to folder with your python interpreter" and "way to folder with your python interpreter"\Scripts\ to PATH variable. Computer -> Properties -> Extra options -> Environment variables.
I have just installed Anaconda on my computer because I need to use Numpy.
Well, when I use python I for some reason have to be in the same folder as python.exe and, of course, now that I want to use Anaconda I have to be in the Anaconda3\Scripts folder where python.exe isn't. This is a nightmare, how can I use anaconda with python on a windows computer? Why does it have to be so complicated?
I think you are referring to the command-line use of python?
If you have admin priviliges on your machine you can add python to your environment variables, making it available in the console anywhere. (Sorry for different spellings, I am not on an english machine)
Press Shift+Pause ("System")
Click "Advanced System Options"
Click "Environment variables"
In the lower field with "System variables" there is a variable called PATH. Append the complete path to your python.exe without the file to that by adding a ; behind the last path in the variable and then adding your path. Do not add any spaces!
Example: C:\examplepath\;C:\Python27\
When you install anaconda on windows now, it doesn't automatically add Python or Conda to your path.
If you don’t know where your conda and/or python is, you type the following commands into your anaconda prompt (it comes when you install anaconda)
Next, you can add Python and Conda to your path by using the setx command in your command prompt.
Next close that command prompt and open a new one. You should now be able to use the python command. To do this you open a command prompt and type
python nameofPythonfile.py
Source: https://medium.com/#GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444
To be able to do that in the command line you just have to add Python and also the Anaconda3\Scripts directory to your system path.
Here is a good tutorial on setting your path in Windows:
http://www.computerhope.com/issues/ch000549.htm
I have installed the Enthought Python distribution on my computer, but I don't have any idea how to use it. I have PyLab and IDLE but I want to run .py files by typing the following command:
python fileName.py
I don't know where to write this command: IDLE, PyLab or Python.exe or Windows command prompt. When I do this in IDLE it says:
SyntaxError: invalid syntax
Please help me to figure this out.
Open a command prompt: Press ⊞ Win and R at the same time, then type in cmd and press ↵ Enter
Navigate to the folder where you have the ".py" file (use cd .. to go one folder back or cd folderName to enter folderName)
Then type in python filename.py
Indeed, the command to run a Python file should be run in the command prompt. Python should be in your path variable for it to work flexible.
When the python folder is added to path you can call python everywhere in the command prompt, otherwise just in your python install folder.
The following is from the python website:
Windows has a built-in dialog for changing environment variables
(following guide applies to XP classical view): Right-click the icon
for your machine (usually located on your Desktop and called “My
Computer”) and choose Properties there. Then, open the Advanced tab
and click the Environment Variables button.
In short, your path is:
My Computer ‣ Properties ‣ Advanced ‣ Environment Variables In this
dialog, you can add or modify User and System variables. To change
System variables, you need non-restricted access to your machine (i.e.
Administrator rights).
Another way of adding variables to your environment is using the set
command in a command prompt:
set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
If you do it via My Computer, then look for the line named path in Enviroment Variables. Give that the value of your Python installation folder.
Set PYTHON variable to point to the full path of python.exe.
Then type in command prompt console window:
C:\path_to_folder\ python filename.py
i've got a problem when i'm doing dev
I managed to use
python manage.py runserver in a CMD shell
but the system cant find python
How could I add python to the system dependency to make the commandline work?
There are two basic ways you can do this in Windows.
Setting the PATH in the cmd shell
The first way is only local to the CMD shell you are currently in, and will have to be done again if you opened a new shell.
You can set your PATH to include the directory where python.exe is located.
In your CMD shell you can do:
set PATH=%PATH%;C:\path\to\python\install
So if Python was installed in C:\Python27, you would do this:
set PATH=%PATH%;C:\Python27
Setting the environment for your user throughout Windows
Alternatively, you can set your PATH permanently by changing the environment variable in Windows. Setting this will affect the rest of your Windows environment.
Right click "My Computer"
Select "Properties"
Click the "Advanced" tab in the new window.
Click on the "Environment Variables" button.
Edit the variable named PATH
Information about doing the latter at Microsoft: http://support.microsoft.com/kb/310519