I am having trouble adding conda to my environment variables on windows. I installed anaconda 3 though I didn’t installed python, so neither pip or pip3 is working in my prompt. I viewed a few post online but I didn’t find anything regarding how to add conda to my environment variables.
I tried to create a PYTHONPATH variable which contained every single folder in Anaconda 3 though it didn’t worked.
My anaconda prompt isn’t working too.
so…How do I add conda and pip to my environment variables or path ?
asked Jun 18, 2018 at 9:08
1
You can access to conda and pip directly in their directory :
- On Windows : %ANACONDA_INSTALL_DIR%\Scripts, you will find conda.exe and pip.exe
- On Linux : $ANACONDA_INSTALL_DIR/bin, there are conda and pip executable files.
Where $ANACONDA_INSTALL_DIR is the directory of your Anaconda installation.
To add Anaconda to your path, you can add this folder to your PATH.
For Linux, you can add this line to yout .bashrc file
export PATH=$ANACONDA_INSTALL_DIR/bin:$PATH
As said @BcK, reinstalling Anaconda and choosing to add Anaconda to your path is also a way to do this. This option makes a backup of your .bashrc file and add the export line.
EDIT
To open a terminal with the conda environment activated on Windows, I usually create a desktop shortcut with the following target :
%windir%\System32\cmd.exe "/K" %ANACONDA_INSTALL_DIR%\Scripts\activate.bat %ANACONDA_INSTALL_DIR%
answered Jun 18, 2018 at 9:17
2
Thanks guys for helping me out. I solved the problem reinstalling anaconda (several times :[ ), cleaning every log and resetting the path variables via set path=
in the windows power shell (since I got some problems reinstalling anaconda adding the folder to PATH[specifically «unable to load menus» or something like that])
answered Jun 18, 2018 at 12:36
The path where Anaconda3 is present on your windows system will not work. C:\Users\pcuser\Anaconda3
Try this:
Open conda prompt and the following
conda list
gives the list of packages. try uninstalling any one package
conda uninstall <any package>
It will prompt the package path where the package is installed. It will look something like this:
c:\users\appdata\local\anaconda3\scripts\
Add this path to my PATH environment-variable. It works from git bash or cmd.
answered Oct 5 at 15:34
RajKRajK
372 bronze badges
Adding conda to path in Windows 10 by 2 steps.
First
Preparation
Open in window «Enviroment variables».
For doing this you need open properties your computer and select «Additional system parameters».
Second
In first or second line search «Path» and click button «Change», then «Create» and «Overview». Then add anaconda location, where you installed conda.
Default:
All users: «/ProgramData/Anaconda3/condabin/»;
Just me: «/Users//Anaconda3/condabin/»;
Custom Path. For searching conda use command:
where conda
.
Third
Test conda in command line.
conda —version
conda activate
conda deactivate
-
System requirements
-
Regular installation
-
Installing in silent mode
-
Installing conda on a system that has other Python installations or packages
The fastest way to obtain conda is to install
Miniconda, a mini version of
Anaconda that includes only conda and
its dependencies. If you prefer to have conda plus over 7,500 open-source
packages, install Anaconda.
We recommend you install Anaconda for the local user, which does
not require administrator permissions and is the most robust
type of installation. You can also install Anaconda system wide,
which does require administrator permissions.
For information on using our graphical installers for
Windows or macOS, see the instructions for
installing Anaconda.
System requirements
-
32- or 64-bit computer
-
For Miniconda: 400 MB disk space
-
For Anaconda: Minimum 3 GB disk space to download and install
-
Windows, macOS, or Linux
-
For Windows: Windows 8.1 or newer for Python 3.9, or Windows Vista or newer for Python 3.8
Note
You do not need administrative or root permissions to
install Anaconda if you select a user-writable install
location.
Regular installation
Follow the instructions for your operating system:
-
Windows
-
macOS
-
Linux
Installing in silent mode
You can use silent installation of
Miniconda or Anaconda for deployment or testing or building
services, such as GitHub Actions.
Follow the silent-mode instructions for your operating system:
-
Windows
-
macOS
-
Linux
Installing conda on a system that has other Python installations or packages
You do not need to uninstall other Python installations or
packages in order to use conda. Even if you already have a
system Python, another Python installation from a source such as
the macOS Homebrew package manager and globally installed
packages from pip such as pandas and NumPy, you do not need to
uninstall, remove, or change any of them before using conda.
Install Anaconda or Miniconda normally, and let the installer
add the conda installation of Python to your PATH environment
variable. There is no need to set the PYTHONPATH environment
variable.
To see if the conda installation of Python is in your PATH
variable:
-
On Windows, open an Anaconda Prompt and run
echo %PATH%
-
On macOS and Linux, open the terminal and run
echo $PATH
To see which Python installation is currently set as the default:
-
On Windows, open an Anaconda Prompt and run
where python
-
On macOS and Linux, open the terminal and run
which python
To see which packages are installed in your current conda
environment and their version numbers, in your terminal window
or an Anaconda Prompt, run conda list
.
Некоторые пользователи сталкиваются с тем, что «conda не распознается как внутренняя или внешняя команда, работающая программа или пакетный файл» при попытке запустить любую команду Anaconda с помощью командной строки .
Что является причиной того, что «conda» не распознается как внутренняя или внешняя командная ошибка?
Мы исследовали эту конкретную проблему, пытаясь воссоздать ошибку на нашем компьютере и просматривая отчеты других пользователей. Исходя из того, что мы собрали, существует несколько сценариев, которые вызывают это конкретное сообщение об ошибке:
- PATH среды для Conda не задан — это наиболее частая причина возникновения данной проблемы. Имейте в виду, что последние сборки Anaconda не будут автоматически добавлять Conda в пути к системным переменным, поскольку это может вызвать различные проблемы с другим программным обеспечением.
- PATH среды добавлен неправильно. Еще одна популярная причина возникновения этой проблемы — ошибка пользователя при попытке вручную добавить переменную PATH среды.
- Версия Anaconda старше, чем версия Anaconda Navigator. Некоторые пользователи сообщают, что ошибка больше не возникает после обновления Conda до последней версии.
Метод 1. Обновление Anaconda до последней версии
Несколько пользователей сообщили, что проблема была решена, и они смогли запускать команды conda внутри командной строки после обновления Conda до последней версии.
Как оказалось, вы можете столкнуться с этой проблемой, если используете новую версию Anaconda Navigator со старой версией Conda. Вот краткое руководство о том, как это исправить:
- Откройте меню «Пуск» в нижнем левом углу и выполните поиск по запросу « анаконда ». Затем нажмите Anaconda Prompt .
- Внутри программы Anaconda Prompt выполните следующие команды и нажимайте Enter после каждой, чтобы обновить Conda до последней версии:
conda update conda install
- Подождите, пока процесс завершится, затем закройте подсказку Anaconda и откройте окно CMD. Посмотрите, можете ли вы теперь запускать команды Conda.
Если вы по-прежнему сталкиваетесь с ошибкой «conda не распознается как внутренняя или внешняя команда, работающая программа или командный файл» , перейдите к следующему способу ниже.
Метод 2: добавление Anaconda в переменную среды PATH во время установки
Самый быстрый способ решить эту проблему автоматически — переустановить Anaconda и использовать один расширенный параметр, который автоматически переведет все Anaconda в вашу переменную среды PATH. Но имейте в виду, что использование этого метода может означать, что вы заставляете определенное приложение конфликтовать с вашей установкой Anaconda.
В любом случае, если вы ищете способ автоматически добавить Anaconda в среду PATH, выполните следующие действия:
Примечание: Если на вашем компьютере не установлена Anaconda, переходите сразу к шагу 3.
- Нажмите клавишу Windows + R, чтобы открыть диалоговое окно «Выполнить». Затем введите « appwiz.cpl » и нажмите Enter, чтобы открыть « Программы и компоненты» .
- Внутри Программы и компоненты , прокрутите вниз по списку приложений и найдите распределение Анаконды . Затем щелкните его правой кнопкой мыши и выберите « Удалить» , затем следуйте инструкциям на экране, чтобы удалить его из вашей системы.
- Перейдите по этой ссылке ( здесь ) и загрузите последний дистрибутив Anaconda, щелкнув значок, связанный с вашей операционной системой.
- Выберите соответствующую версию Python, которую вы хотите использовать с Anaconda, нажав соответствующую кнопку « Загрузить» .
- Откройте исполняемый файл установки, нажмите « Далее» в первом запросе и примите лицензионное соглашение .
- Выберите тип установки и еще раз нажмите Далее .
- Выберите папку назначения и снова нажмите кнопку « Далее» . Мы настоятельно рекомендуем оставить местоположение по умолчанию.
- Этот шаг очень важен. В разделе « Дополнительные параметры установки» установите флажок « Добавить Anaconda в мою переменную среды PATH» (в разделе « Дополнительные параметры» ) и нажмите « Установить» .
- После завершения установки введите « conda » в командной строке. Вы больше не должны видеть ошибку «conda не распознается как внутренняя или внешняя команда, работающая программа или командный файл» .
Если этот метод оказался неэффективным или вы ищете другой подход, который не требует переустановки всего дистрибутива Anaconda, перейдите к следующему методу ниже.
Метод 3: добавление пути Conda вручную
Если вы не хотите тратить время на удаление всего дистрибутива Anaconda, вы можете самостоятельно обновить (или проверить) переменную среды, связанную с Conda. Но перед этим важно выяснить точное местоположение вашей установки Conda.
Следуйте приведенному ниже руководству, чтобы узнать и настроить Conda PATH вручную в переменных среды:
- Войдите в меню «Пуск» (нижний левый угол) и выполните поиск по запросу « анаконда ». Затем нажмите Anaconda Prompt и дождитесь открытия программы.
- В программе Anaconda Prompt выполните следующую команду и нажмите Enter, чтобы проверить расположение Conda:
где конда
- Скопируйте второе местоположение, ранее полученное на шаге 2, но исключите исполняемый файл. Например: C: \ Users \ madro \ Anaconda3 \ Scripts
- Нажмите клавишу Windows + R, чтобы открыть диалоговое окно «Выполнить». Затем введите « sysdm.cpl » и нажмите Enter, чтобы открыть экран « Свойства системы» .
- В окне « Свойства системы» перейдите на вкладку « Дополнительно » и нажмите « Переменные среды».
- В окне « Переменные среды» для окна * YourUser * выберите переменную Path и нажмите кнопку « Изменить» .
- В окне « Изменить переменную среды» нажмите кнопку « Создать» . Затем добавьте эти два места:
C: \ Users \ * YourUser * \ Anaconda3 \ Scripts C: \ Users \ * YourUser * \ Anaconda3
Примечание. Имейте в виду, что * YourUser * — это только заполнитель. Замените его своим именем пользователя. Кроме того, если вы используете старую версию Anaconda, измените номер версии соответствующим образом.
Метод 4: решение проблемы без добавления Anaconda в путь к среде
Если вы хотите избежать добавления пути Anaconda к переменным среды, вы можете вводить команды Conda, не получая сообщения об ошибке «conda не распознается как внутренняя или внешняя команда, работающая программа или пакетный файл» , используя командную строку для перехода к папке. установка в первую очередь.
Но имейте в виду, что это не очень практично, так как вам придется повторять эту процедуру всякий раз, когда вы открываете новую командную строку.
Если вы решили обойти ошибку, добавив путь к Anaconda в окно CMD, вам нужно сделать следующее:
- Нажмите клавишу Windows + R, чтобы открыть диалоговое окно «Выполнить». Затем введите « cmd » и нажмите Enter, чтобы открыть диалоговое окно « Выполнить ».
- В окне CMD введите CD, а затем укажите путь к папке, в которой установлена ваша Anaconda. Если вы не установили Anaconda в аналогичном месте, он должен быть примерно таким:
Компакт-диск C: \ Users \ * YourUser * \ Anaconda3 \ Scripts
- Запустите команду, чтобы протестировать Anaconda и посмотреть, правильно ли она работает в командной строке. Вы можете использовать эту команду:
conda --version
Original text
Contribute a better translation
conda is an open source, cross-platform package and environment manager which runs on multiple platforms including Windows, Linux and macOS.
It was originally created for installing and managing multiple versions of Python packages, but can be extended to support many other languages such as R, Ruby, Lua, JavaScript, etc.
If you’re already familiar with Python, imagine conda as pip and virtualenv combined.
This article is going to show you how to fix conda “command not found” (in Linux and macOS) or “not recognized as internal or external command” in Windows.
Different form of the same error
Any OS has some kind of system variable containing the paths where they would find commonly-used executables, so that they can allow you to run these without specifying the full path. That system variable is called PATH
or $PATH
.
Let’s suppose the PATH
contains /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games
.
When you run, for example, conda
, the OS is going to search for conda
inside one of these path, if it’s found, it will be executed, if not, “command not found” error will be spit out.
The error message may look different across operating system and terminals. Usually on Linux, it could be bash: conda: command not found
. On macOS with zsh, the error is zsh: command not found: conda
. On Windows, conda not recognized as internal or external command
would be displayed.
Please note that normally you would have to run conda
using the full path, for example, /usr/bin/conda
. PATH
system variable enable a way to quickly reach commonly-used executables.
To sum it up, conda “command not found” (in Linux and macOS) or “conda not recognized as internal or external command” in Windows simply indicates that the operating system cannot find conda in one of the directories where executables are usually placed.
Add conda to PATH environment variable
The first thing you should do is to add conda
to PATH
environment variable. Normally this was done automatically by the Anaconda installer or package manager, but you need to be sure the OS knows where to look for conda
.
On Linux
On Linux, you can add conda
to PATH
using export
. Open up a terminal and run the following command.
export PATH=/path/to/anaconda3/bin:$PATH
Code language: JavaScript (javascript)
Replace /path/to/anaconda3/bin
to where you place anaconda3
, usually it was installed in /home/your_username
.
The command makes changes to the current session only and will not persistent though restarts.
If you don’t want to do this every time you start a session, you can add that command into .bashrc
file so that it is starts up with the terminal.
echo 'export PATH=/path/to/anaconda3/bin:$PATH' >> ~/.bashrc
Code language: PHP (php)
On Windows
On Windows, you have to go to Control Panel > System and Security > System > Advanced System Settings, look for System Variables.
Under the System Variables section, find the row named Path and click Edit. You need to add
You need to add the Anaconda installation folder C:Usersyour_usernameAnaconda3
(replace your_username
with your actual account name) to the list of paths.
Use conda init
init
is a new command added to Conda v4.6 and later to ensure users have a properly configured terminal set up automatically.
We prefer adding conda
to PATH
ourselves, but if that doesn’t work out for you, maybe you should try running the following command:
Linux/UNIX (OS X < 10.15)
./anaconda3/bin/conda init
Mac OS X >= 10.15
./anaconda3/bin/conda init zsh
Windows
./anaconda3/Scripts/conda.exe init
zsh users
./anaconda3/bin/conda init zsh
The init
command supports other shells, too, including bash
, cmd.exe
, fish
, powershell
, tcsh
, xonsh
, zsh
.
Once the script is done running, you must launch a new terminal command for the settings to take effect.
If things didn’t go well, you can always reverse the changes made by conda init
by running
./anaconda3/bin/conda init --reverse
Set up zsh to read .bashrc
If you’re just switching to zsh and getting the following error message, you might not set up zsh to read .bashrc
.
In any terminal, run nano ~/.zshrc
to edit zsh configuration file and add the following line to it.
source ~/.bash_profile
Now close your terminal and open it all over again, verify that zsh now loads bash configuration and conda
works again.
conda not recognized on Windows
On Windows, you should get 'Conda' is not recognized as internal or external command
if the OS does not find it in the PATH
.
Recent Windows 10 releases does not assume you have administrator privileges to install or update. You can force administrative re-installation by right-click on the Anaconda Command Prompt, choose “Run as administrator“.
Alternatively, you can use Anaconda Navigator or the Anaconda Command Prompt (located in the Start Menu under “Anaconda”) when you wish to use Anaconda software, as per Anaconda recommendation.
conda not found in Git Bash
If you use Git Bash on Windows, it is out of conda init
support.
In order to manually configure conda
to work with the Git Bash shell, you need to add conda.sh
from Anaconda3 installation into .bashrc
.
First, open up C:ProgramDataAnaconda3etcprofile.d
, right-click in any blank space and select Git Bash Here to open up a new Git Bash terminal right where you are now.
After that, copy and paste the following command into the terminal and run it.
echo ". '${PWD}'/conda.sh" >> ~/.bashrc
Code language: PHP (php)
Basically it puts a new line in the current .bashrc
configuration file that loads conda.sh
every time it starts.
We hope that you’ve learned how to fix conda “command not found” error and get it to work again. Conda is a great package manager designed specifically for data scientist and the users who are not familiar with Python, pip and pipenv/virtualenv as a whole.
If you want to learn more about Python, check out our other posts about common errors in Python such as “too many values to unpack” or locale.Error: unsupported locale setting.