Anaconda (Python) - Cmder integration on Windows 10
Asked Answered
D

4

9

I'm having some troubles in having Cmder working with Python through Anaconda on Windows 10 64bit.

I got Anaconda working pretty well, tested to plot something with matplotlib and it works just great with Anaconda Prompt. However, if I try to run the same .py file under Cmder, I got the following error:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
    from . import multiarray
ImportError: DLL load failed: The specified module could not be found.

I guess it has something to do with the path of the environment vars, but I have already added to the path the following:

  1. C:\ProgramData\Anaconda3\
  2. C:\ProgramData\Anaconda3\Scripts\
  3. C:\ProgramData\Anaconda3\Lib\

Any hints?

Thanks

Daybook answered 2/3, 2019 at 15:8 Comment(0)
S
33

Assume your Anaconda3 installation path is C:\ProgramData\Anaconda3. On your Cmder settings StartupTasks, add a new predefined tasks

name:

whatever

and command:

cmd /k ""%ConEmuDir%\..\init.bat"" & C:\ProgramData\Anaconda3\Scripts\activate.bat C:\ProgramData\Anaconda3

To find the Anaconda path use the following command on Anaconda Prompt:

where anaconda

For example C:\ProgramData\Anaconda3\Scripts\anaconda.exe, the path will be C:\ProgramData\Anaconda3

Serene answered 4/3, 2019 at 5:1 Comment(3)
It seems like the value entered after C:\ProgramData\Anaconda3\Scripts\activate.bat command becomes the string in () to left of current line in Cmder. Typically anaconda starts with (base). To follow this convention, I just used the command cmd /k ""%ConEmuDir%\..\init.bat"" & C:\ProgramData\Anaconda3\Scripts\activate.batMakell
Just as an FYI, if your directory/%ConEmuDir% has spaces, make sure you handle this correctly in your commands - see: #12891883Astrogation
It's cmd /k ""%ConEmuDir%\ConEmu\CmdInit.cmd"" & ... now. (init.bat no longer exists)Deist
V
3

It is a two step process:

  1. Add anaconda installation directory to PATH environment variable. In my case the directory to be added is C:\ProgramData\Anaconda3\Scripts. Don't forget to add till Scripts. Restart cmder and see that conda should start working now. Refer Adding a directory to the PATH environment variable in Windows
  2. Do conda init cmd.exe. With this command some initializations will happen and your cmder prompt will start acting exactly like anaconda prompt. Restart cmder and now, you can use commands like conda activate <env_name> to activate environment of your choice.

Now, you can have Linux like terminal with all options of anaconda prompt in your Windows machine.

Vincennes answered 16/1, 2022 at 18:9 Comment(0)
A
1

Another way of doing it for miniconda:

  1. Copy the location to the scripts folder; in my case it was:

    C:\Users\yourname here\miniconda3\Scripts

  2. In the start menu type edit and choose edit environment variables

  3. In the window add new variable name it Path and give it a value of the aforementioned path

  4. Restart Cmder and enjoy!

Ardeha answered 14/5, 2021 at 20:18 Comment(0)
T
0

This can be setup pretty conveniently in a similar fashion to the accepted answer by setting up a new task in cmder that looks like this:

set "PATH=[PATH_TO_YOUR_ANA/MINICONDA_INSTALL];%PATH%" & 
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& '[PATH_TO_YOUR_ANA/MINICONDA_INSTALL]\shell\condabin\conda-hook.ps1' ; conda activate '[PATH_TO_YOUR_ANA/MINICONDA_INSTALL]' "

The second line is actually just a copy paste of what the conda-powershell is doing by default.

Convenient steps to reproduce are:

  1. find the link to the (ana/mini)-conda-powershell-executable from your windows-search-bar
  2. right-click
  3. open folder
  4. right-click on the prompt you want to integrate with cmder (in my example above it's the powershell-type)
  5. properties
  6. copy the content of destination-field (i assume it is named like that in English versions of Win10) and you already get the proper second part of my snippet above
  7. add the first line that sets the PATH with your individual path to Ana/Miniconda

The first line is mainly there to reduce pollution of your permanent PATH by a bit. Be aware not to overwrite the ;%PATH% when you copy-paste your ana/miniconda-path into the first line.

Please also be aware that the second line might look a bit different depending on your installation, hence I recommend to not just copy-paste my snippet but rather follow the steps to reproduce that I provided.

Titoism answered 8/5, 2022 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.