Reputation: 576
I have Miniconda3 installed at C:\Users\me\Miniconda3, and my 'Project Interpreter' within PyCharm set to my conda environment, and that is all working correctly. However it appears that conda is not set for my path variable as if I type conda
into the PyCharm Terminal I get
'conda' is not recognized as an internal or external command, operable program or batch file.
Is there a way to set the PyCharm Terminal to behave like the Anaconda Prompt?
I have Windows 10, PyCharm 2018.1 EAP, and conda 4.4.10 installed.
Upvotes: 29
Views: 31473
Reputation: 2836
In case you are using Miniconda , Windows 11 and Pycharm Community Edition
In Shell Path set below path replacing you respective user id
cmd.exe "/K"
C:\Users\your_user_Id\AppData\Local\miniconda3\Scripts\activate.bat
C:\Users\your_uesr_id\AppData\Local\miniconda3
Upvotes: 3
Reputation: 357
Type in Anaconda Prompt conda env list to retrieve the conda path. Move to the folder with your bash (eg : GitBash):
cd <conda path>/etc/profile.d
And add conda to the ~/.basrc file :
echo ". ${PWD}/conda.sh" >> ~/.bashrc
Activate the modifications of your ~/.basrc :
source ~/.bashrc
Upvotes: 0
Reputation: 604
Here's what I got to work (its a variation of dd. post):
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\ProgramData\Anaconda3' "
-ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\ProgramData\Anaconda3' "
(this is part of the path above)
In fact, the full version can be written directly as
powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\ProgramData\Anaconda3' "
No need to explicitly specify the path to powershell. (Still need to replace the path to anaconda with your own.)
(also make sure there is a space between the end of the powershell path and the dash)
Upvotes: 1
Reputation: 1415
For window user, first of all check the location of your anaconda environment
you could type conda env list
to show
For my case, the env I want to have my anaconda prompt is located at C:\Users\YOURUSERNAME\Anaconda3\
(which is the root env, the very first you get)
And then go to pycharm, go settings, go Tools, Inside Shell path enter
cmd.exe "/K" C:\Users\YOURUSERNAME\Anaconda3\Scripts\activate.bat C:\Users\YOURUSERNAME\Anaconda3
Upvotes: 9
Reputation: 473
Great answer by dd.
It helped me out as well, but I chose to do it in a slightly different way in PyCharm.
It appears we can get the Anaconda prompt running in the PyCharm terminal without having to redirect to a new Shell path, ie. we may keep the original Shell path which in my case is "C:\Windows\System32\cmd.exe"
for Windows 10. And instead point to the Environment Variables that are used by the conda command prompt, in the following way:
echo %PATH
from the conda command prompt as described here in the answer by Rob
/ Adrian
. If you have already set the PATH for the python interpreter in PyCharm you can find it here: Settings - Build, Execution, Deployment - Console - Python Console
. Click the folder button to the right of Environment variables input and then copy the path value from the Value field to the right of the variable under NameSettings - Tools - Terminal
+
symbol. Name it PATH
and paste in the previously copied value. Click OK and then ApplyYou could restart PyCharm, or close and restart Terminal within PyCharm, in order to make sure the changes have been recognized.
Now you should be able to use for instance both pip list
and conda list
within the same Terminal window within PyCharm. In my case the former command returns a smaller list compared to the larger list from the other command (from conda).
Regardless, it appears you should now be able to use both within one, ie. to use the same Terminal window to perform conda and regular python operations, for instance for installations.
Sidenote: Though the two-in-one option works for the Terminal windows it does not seem to work for the Python Console - where I use the conda one within PyCharm. In that Console it currently only recognize packages from the conda interpreter and not the packages from my previous regular python interpreter.
Anyway, hope this helps other people! If anyone has any insights into whether or not this is a viable solution in the long run, please let me know.
Upvotes: 0
Reputation: 63
The shell path may differ, you can check from the properties of shortcut of 'Anaconda Prompt': rightClick on the icon of 'Anaconda Prompt' >> properties >> shortcut >> Target
Upvotes: 3
Reputation: 866
You can change pycharm settings to achieve this.
In Settings > Tools > Terminal, change the Shell path
as following:
cmd.exe "/K" "C:\Users\me\Miniconda3\Scripts\activate.bat" "C:\Users\me\Miniconda3"
And the C:\Users\me\Miniconda3
can be replaced by either one of your conda environment name such as base
Close the Terminal and reopen it, you will get the Anaconda prompt.
It works in my PyCharm Community Edition 2018.1.2
Upvotes: 58