wuub / SublimeREPL

SublimeREPL - run an interpreter inside ST2 (Clojure, CoffeeScript, F#, Groovy, Haskell, Lua, MozRepl, NodeJS, Python, R, Ruby, Scala, shell or configure one yourself)
https://github.com/wuub/SublimeREPL
Other
2.14k stars 312 forks source link

Anaconda Python environment not activated when running from SublimeText3 SublimeREPL package #576

Open ZyzotPerplex opened 5 years ago

ZyzotPerplex commented 5 years ago

I am using SublimeText3 with the SublimeREPL package and the Miniconda python installation. I have followed the instructions listed here to run python from SublimeText3 with a custom environment:

https://stackoverflow.com/questions/20861176/how-do-i-setup-sublimerepl-with-anacondas-interpreter

Yet, when I run the Python interpreter from SublimeText3, I initially get

Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

If I then try to

import numpy

I get the following error message:

>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\USER\Miniconda3\envs\CUSTOM_ENV\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\USER\Miniconda3\envs\CUSTOM_ENV\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

For other packages such as sympy, I don't get an error when I try to import the package.

Similarly, if I run anaconda from the anaconda prompt and import numpy, it runs without errors.

So it seems that it is calling python from the custom environment but thinks the environment isn't activated and can't load Numpy.

Post is cross-posted here:

https://stackoverflow.com/questions/56713189/anaconda-python-environment-not-activated-when-running-from-sublimetext3-sublime

weidongzhou1994 commented 4 years ago

I also encounter the same problem.

janxkoci commented 4 years ago

I use R from conda, but this should work for other REPLs too. Copy this into user settings of SublimeREPL:

{
    "default_extend_env": {"PATH": "/home/jena/miniconda3/bin:{PATH}"}
}

Obviously tweak the path to correspond to your installation :wink:

Edit: I myself used the second answer from your link, long time ago. Tried this on many linux machines, works every time.