Duplicating the Python 3 executable python.exe
and renaming it to python3.exe
suggested in another answer is a terrible idea, please don’t do it, because you would have to repeat it every time you upgrade Python to a newer version and it’s likely that you’ll forget it and you’ll be surprised that your Python is broken after the upgrade.
I suggest the following simple setup.
Solution: Symbolic Link python3.exe
Just create a symbolic link named python3.exe
in a directory which is in your PATH
environment variable (but which is not under the Python 3 installation directory) pointing to the Python 3 executable python3/python.exe
. The symbolic link stays there and keeps pointing to the correct executable even if you upgrade the Python (since it’s outside the Python 3 installation directory, it’s not affected even when the whole directory of an outdated Python is deleted and a new Python is placed there).
It’s very easy to prepare:
- Execute an elevated Powershell Core (
pwsh.exe
), Powershell (powershell.exe
), or Windows command shell (cmd.exe
) - Decide where you want to create the symbolic link:
- Pick a directory already in your
PATH
environment variable (useecho $env:PATH
in Powershell orecho %PATH%
incmd.exe
to print the variable contents) - Add any directory you like to the
PATH
variable (see below)
- Pick a directory already in your
- Navigate to the directory you chose in the previous step and create there a symbolic link named
python3.exe
pointing to the Python 3 executable (thetarget
parameter), both paths may be absolute or relative:-
in Powershell, use the
New-Item
command with the-Type SymbolicLink
option:New-Item -Type SymbolicLink -Path python3.exe -Target c:\<Python3-installation-directory>\python.exe
-
in
cmd.exe
, use themklink
command:mklink python3.exe c:\<Python3-installation-directory>\python.exe
-
Now, if you execute python3
or python3.exe
from any directory, Windows searches it in the current directory and then all directories in your PATH
environment variable. It finds the symbolic link you have created which «redirects» it to the Python 3 executable and Windows executes it.
Notes
Which version executes python
command?
What Python version is being executed by the command python
when both Python 2 and 3 are installed, depends on the order of Python directories in the PATH
environment variable.
When you execute a command and it’s not being found in the current working directory, Windows iterates through all directories in the PATH
variable while keeping the order as they’re listed there and executes the first executable whose name matches the command (and it stops the searching).
So, when your PATH
variable contains Python installation directories in the order c:\dev\python2\;c:\dev\python3;...
, then the python
command executes python.exe
in the c:\dev\python2\
because it was found first.
The order depends on the order in which you have installed both Python versions. Each installation adds (if you check that option) its instalation directory at the beggining of PATH
, so the most recently installed version will be executed when you execute just python
. But you can reorder them manually, of course.
pip
There’s no issue with pip, because there’s already an executable named pip3.exe
that’s located in a directory automatically added to the PATH
during the installation by Python (<installation-root>\Scripts
, so just use pip3
for the Python 3’s pip and pip
/pip2
for the Python 2’s pip.
Editing Environment Variables
- Open the Windows’ About dialog by pressing Win + Pause/Break or right-clicking This PC and selecting Properties
- Open the System Properties dialog by clicking the link Advanced system settings on the right side of the Settings dialog
- Open the Environment Variables dialog by clicking the button Environment Variables… at the bottom of the System Properties dialog
- Here, you can manage user variables and if you have the admin rights then also system variables
Apologies if this is a basic question:
I have been trying to setup Python on my laptop by following the tutorial here. Under PIP, VIRTUALENV + VIRTUALENVWRAPPER subtitle, it says
-
And now setup virtualenvwrapper:
1 $ export WORKON_HOME=$HOME/.virtualenvs 2 $ export MSYS_HOME=/c/msys/1.0 3 $ source /usr/local/bin/virtualenvwrapper.sh
The last line of above gives me the following error:
$ source /usr/local/bin/virtualenvwrapper.sh
sh.exe": /usr/local/bin/virtualenvwrapper.sh: No such file or directory
So when I test my setup I get the following error:
$ mkvirtualenv TestEnv
sh.exe": mkvirtualenv: command not found
Could some1 help me out please?
THis is all on a Win7 laptop.
Thanks.
matcheek
4,8879 gold badges45 silver badges73 bronze badges
asked Sep 8, 2013 at 13:29
5
From what you wrote it looks to me that you are mixing Windows and Linux shell commands.
I strongly advocate you get the virtualenv working first before you turn to a wrapper
To get virtualenv on Windows 7
pip install virtualenv
then
virtualenv name_to_your_env
name_to_your_env\Scripts\activate
answered Sep 8, 2013 at 13:53
matcheekmatcheek
4,8879 gold badges45 silver badges73 bronze badges
6
I was having this same problem but got it to work a different way in Windows.
pip install virtualenv
virtualenv venv
.\venv\Scripts\activate.bat
The key here is running activate.bat rather than just activate. Once I did this and closed and opened cmd again and tried the normal
.\venv\Scripts\activate
it worked. I don’t know why but it worked for me, hopefully it helps somebody else.
answered Feb 3, 2016 at 0:12
smoosh911smoosh911
5267 silver badges8 bronze badges
According to your comment, virtualenvwrapper.sh
is not in /usr/local/bin
.
You should pass correct path to source
command.
source /path/to/..../Scripts/virtualenvwrapper.sh
answered Sep 8, 2013 at 13:51
falsetrufalsetru
358k63 gold badges735 silver badges638 bronze badges
5
I had encountered with the same problem and solved it by downloading mktemp binary
for windows and uncompressing it under git/bin. Then it works. (I was trying to run leiningen
[lein help] command under Git Bash, on Windows 7)
This is the download site i visited.
Riad
3,8225 gold badges28 silver badges39 bronze badges
answered Nov 16, 2014 at 18:15
Duplicating the Python 3 executable python.exe
and renaming it to python3.exe
suggested in another answer is a terrible idea, please don’t do it, because you would have to repeat it every time you upgrade Python to a newer version and it’s likely that you’ll forget it and you’ll be surprised that your Python is broken after the upgrade.
I suggest the following simple setup.
Solution: Symbolic Link python3.exe
Just create a symbolic link named python3.exe
in a directory which is in your PATH
environment variable (but which is not under the Python 3 installation directory) pointing to the Python 3 executable python3/python.exe
. The symbolic link stays there and keeps pointing to the correct executable even if you upgrade the Python (since it’s outside the Python 3 installation directory, it’s not affected even when the whole directory of an outdated Python is deleted and a new Python is placed there).
It’s very easy to prepare:
- Execute an elevated Powershell Core (
pwsh.exe
), Powershell (powershell.exe
), or Windows command shell (cmd.exe
) - Decide where you want to create the symbolic link:
- Pick a directory already in your
PATH
environment variable (useecho $env:PATH
in Powershell orecho %PATH%
incmd.exe
to print the variable contents) - Add any directory you like to the
PATH
variable (see below)
- Pick a directory already in your
- Navigate to the directory you chose in the previous step and create there a symbolic link named
python3.exe
pointing to the Python 3 executable (thetarget
parameter), both paths may be absolute or relative:-
in Powershell, use the
New-Item
command with the-Type SymbolicLink
option:New-Item -Type SymbolicLink -Path python3.exe -Target c:\<Python3-installation-directory>\python.exe
-
in
cmd.exe
, use themklink
command:mklink python3.exe c:\<Python3-installation-directory>\python.exe
-
Now, if you execute python3
or python3.exe
from any directory, Windows searches it in the current directory and then all directories in your PATH
environment variable. It finds the symbolic link you have created which «redirects» it to the Python 3 executable and Windows executes it.
Notes
Which version executes python
command?
What Python version is being executed by the command python
when both Python 2 and 3 are installed, depends on the order of Python directories in the PATH
environment variable.
When you execute a command and it’s not being found in the current working directory, Windows iterates through all directories in the PATH
variable while keeping the order as they’re listed there and executes the first executable whose name matches the command (and it stops the searching).
So, when your PATH
variable contains Python installation directories in the order c:\dev\python2\;c:\dev\python3;...
, then the python
command executes python.exe
in the c:\dev\python2\
because it was found first.
The order depends on the order in which you have installed both Python versions. Each installation adds (if you check that option) its instalation directory at the beggining of PATH
, so the most recently installed version will be executed when you execute just python
. But you can reorder them manually, of course.
pip
There’s no issue with pip, because there’s already an executable named pip3.exe
that’s located in a directory automatically added to the PATH
during the installation by Python (<installation-root>\Scripts
, so just use pip3
for the Python 3’s pip and pip
/pip2
for the Python 2’s pip.
Editing Environment Variables
- Open the Windows’ About dialog by pressing Win + Pause/Break or right-clicking This PC and selecting Properties
- Open the System Properties dialog by clicking the link Advanced system settings on the right side of the Settings dialog
- Open the Environment Variables dialog by clicking the button Environment Variables… at the bottom of the System Properties dialog
- Here, you can manage user variables and if you have the admin rights then also system variables
В последние несколько недель некоторые люди сталкивались с сообщением об ошибке, в котором тип команды Python не найден в Windows. Эта проблема может возникнуть по нескольким причинам. Давайте посмотрим ниже.
Одобрено: Fortect
Повысьте производительность вашего компьютера с помощью этой простой загрузки. г.
Я определенно установил некоторые из последних версий Win10 на python для Windows.Просто специальный тип py
при запуске окна управления
командной строки Python.
Microsoft Windows [версия 10.0.15048](c) Корпорация Microsoft, 2017 г. Все юридические зарезервированы.C: Users sg7> pyPython 3.6.3 (v3.6.3: 2c5fed8 октября 2017 г., 3 18:11:49) [MSC v.1900, 64-разрядная версия (AMD64)] на win32Введите Help, Copyright, Credits. Более подробную информацию вы найдете в разделе «Лицензия».>>> `Введите сюда любой код`
>>> распечатать («Привет!»)Привет!>>>
Обратите внимание, что в моем случае Python был установлен в каталоге C: Users sg7 AppData Local Programs Python Python36>
C: Users sg7 AppData Local Programs Python Python36> каталог Том перед диском C - это том windows7_os Серийный номер 1226-12D1. Каталог C: Users sg7 AppData Local Programs Python Python3608.05.2018 07:38
.08.05.2018 07:38
..18.12.2017 09:12
DLL18.12.2017 09:12
Док18.12.2017 09:12
в комплекте18.12.2017 09:12
Lib18.12.2017 09:12
библиотеки03.10.2017 19:17 30.334 LICENSE.txt03.10.2017 19:17 362.094 NEWS.txt10.03.2017 19:15 100,504 python.exe10.03.2017 19:12 пятьдесят восемь 520 python3.dll10.03.2017 19:12 3 610 776 python36.dll10.03.2017 19:15 98.968 pythonw.exe05.08.2018 07:38 196.096 Удаляет cons.exe08.05.2018 07:38 25 563 scons-wininst.log08.05.2018 07:38 Скрипты
18.12.2017 09:12 tcl18.12.2017 09:12 инструменты09.06.2016 23:53 87.888 vcruntime140.dll 9 песен 4571743 байта десять Dir (s) 20,228,898,816 свободных байтов
Если бы я был в списках C: Users sg7>
, python
мог бы дополнительно быть вызывается с момента ввода AppData Local Programs Python Python36 python
C: Users samg> AppData Local Programs Python Python36 pythonPython 3.6.3 (v3.6.3: 2c5fed8 октября 2017 г., 3 18:11:49) [MSC v.1900, шестьдесят четыре слова (AMD64)] на win32Для получения дополнительной информации введите «Справка», «Авторские права», «Авторы» или «Лицензия».>>>
При желании клиент может добавить в эту специальную переменную сообщества path следующее:% USERPROFILE% AppData Local Programs Python Python36
Решение
Найдите папку с достаточным обоснованием для фактической установленной версии Python, как указано в
). Если папки определенно нет, загрузите и установите последнюю популярную версию Python здесь.X: Program Files
(где X X encoding = "application x-tex"> X C: Programs Python36-
Откройте эту папку и способ ее копирования.
-
Одобрено: Fortect
Fortect — самый популярный и эффективный в мире инструмент для ремонта ПК. Миллионы людей доверяют ему обеспечение быстрой, бесперебойной и безошибочной работы своих систем. Благодаря простому пользовательскому интерфейсу и мощному механизму сканирования Fortect быстро находит и устраняет широкий спектр проблем Windows — от нестабильности системы и проблем с безопасностью до проблем с управлением памятью и производительностью.
- 1. Загрузите Fortect и установите его на свой компьютер.
- 2. Запустите программу и нажмите "Сканировать"
- 3. Нажмите "Восстановить", чтобы устранить обнаруженные проблемы.
Щелкните правой кнопкой мыши в отношении этого ПК, затем перейдите в «Свойства» => «Расширенная система» => «Управление переменными среды».
В окне, которое выглядит как переменная Path
, выберите ее, затем нажмите «Изменить»; В противном случае регистр break New.
В диалоговом окне добавления нажмите «Создать» и сначала назначьте скопированный путь к этой ценной папке; Затем нажмите ОК.
Повысьте производительность вашего компьютера с помощью этой простой загрузки. г.
Python не работает в командной строке для каждой оболочки Не забудьте добавить обновленную прогулку в ~ /. bash_profile. См. Следующий URL: UNIX / Linux: установите переменную PATH, управляющую командой set или export.
Ошибка «Python не распознается всякий раз, когда внутренняя или дополнительная команда» появляется в текущей командной строке Windows. Ошибка возникает, когда часто исполняемый файл Python не распознавался в переменной атмосферы в результате выполнения команды Python в командной строке Windows.
Сценарий Python 3 c #! Линия продуктов python3 shebang не будет работать, если учесть, что python3.exe на самом деле не существует в Windows – это должно быть достигнуто с помощью py -3. Чтобы исправить это, добавьте этот скрипт в свой PATH через python3: Следующий вызов вызывает правильную команду Python, в зависимости от операционной системы (также работает по отношению к Windows и Linux).
г.
Related Posts:
- Простая стратегия решения проблем с кодеком MKV в…
- Простая стратегия исправить переносимые антивирусные…
- Лучшая стратегия для исправления переустановки Windows Vista…
- Лучшая стратегия для исправления Vbscript, если ошибки…
- Лучшая стратегия для исправления ошибки: не удается найти…
- Простая процедура исправления модели OSI с исправлением…
If you’re a programmer, especially a beginner, you’ve probably run across the annoying issue where Python cannot be found by the Command Prompt (CMD).
This error message could make it impossible for you to execute Python scripts and might have an impact on your software development and coding tasks.
Yet, there is an easy fix for this issue, which is a common one.
In this article, we’ll examine the reasons behind the “CMD Can’t Locate Python” problem message, its various potential settings, and potential solutions. After reading this article, you ought to be able to solve the issue and successfully run Python scripts in the Command Prompt.
Advertising links are marked with *. We receive a small commission on sales, nothing changes for you.
What does the error message “CMD Can’t Find Python” mean exactly?
When the Command Prompt is unable to find the Python interpreter, which is necessary to run Python programs, the error message “CMD Can’t Find Python” occurs.
You can encounter an error message similar to this while attempting to launch a Python script in the Command Prompt:
Python is not accepted as an operating system, executable application, or batch file.
Typical excuses for Python not being found in CMD The Command Prompt may be unable to find Python for several reasons:
- There is an improper configuration of the PATH environment variable.
- Your machine does not have Python installed.
- The PATH does not contain the location where Python is installed.
- The installation of Python is flawed or lacking.
- Possible remedies
You can try a few alternatives to address the issue if you encounter the “CMD Can’t Locate Python” error message.
Read on!
A Step-by-Step Approach to Resolving the “CMD Can’t Find Python” Issue
This part will provide a step-by-step guidance to applying the solutions presented in section III.
To resolve the “CMD Can’t Find Python” error message, follow these steps:
#1: Set up the PATH environment variable to direct CMD to Python
A wrongly set PATH environment variable is one of the most frequent reasons why Python cannot be found by the Command Prompt. Add the directory where Python is installed to the PATH environment variable to solve this problem.
This is how:
- Enter “Environment Variables” in the search field of the Start menu.
- “Edit the system environment variables” should be selected.
- Choose “Environment Variables” from the menu.
- Click “Edit” next to “Path” in the “System Variables” section.
- Choose “New,” then enter the location where Python is installed (for example, C:Python39).
- If you click “OK,” all windows will be closed.
#2: Reinstall Python.
You can reinstall Python if setting up the PATH environment variable does not work.
This is how:
- You should uninstall Python from your computer.
- Visit the Python website to download the most recent version.
- Run the installation wizard and adhere to the instructions to install Python.
- Check the box to add Python to the PATH environment variable during the installation process.
#3: Check for CMD issues in the Python installation directory.
Make sure the Python installation path is in the PATH environment variable if you’re still experiencing difficulties running Python scripts in the Command Prompt.
This is how:
- Enter “Python” into the search bar on the Start menu.
- “Python” should be selected when you right-click it.
- Transfer the directory path.
- To add the directory path to the PATH environment variable, follow the instructions in Solution 1.
By following these instructions, you ought to be able to get rid of the “CMD Can’t Find Python” error notice and successfully run Python applications in the Command Prompt. We’ll lead you through the implementation of these solutions in the following section.
Conclusion
Although the “CMD Can’t Find Python” error message can be annoying, there are several fixes available.
In this article, we’ve provided a step-by-step procedure for resolving the problem, whether it be by installing Python again or by changing the PATH environment variable. These methods should enable you to successfully launch Python scripts from the Command Prompt.
Remember to restart your computer and run the Python script once more if you’re still experiencing issues after trying these solutions.
If you’re still experiencing issues, you might need to seek more help or troubleshooting.
We sincerely hope that this article was helpful in resolving the “CMD Can’t Find Python” issue.
Coding is fun!
FAQ
How should I interpret “CMD Can’t Find Python”?
When the Command Prompt is unable to find the Python interpreter needed to run Python programs, the error message “CMD Can’t Find Python” occurs.
The error notice “CMD Can’t Find Python”—how can I fix it?
Change the PATH environment variable to include the Python installation path, reinstall Python, or look in the Python installation directory to fix the “CMD Can’t Find Python” problem.
Why is Python not found in CMD?
Due to incomplete or damaged Python installations, poorly configured PATH environment variables, or Python not being installed on your system, Python may not be found in CMD.
Advertising links are marked with *. We receive a small commission on sales, nothing changes for you.