ContinuumIO / anaconda-issues

Anaconda issue tracking
646 stars 220 forks source link

Default python version of Sublime Text 3 is not anaconda #12174

Open neo2887 opened 3 years ago

neo2887 commented 3 years ago

Actual Behavior

Hi guys, I use Sublime Text 3 and Anaconda package to code in python on OS Catalina. My python version is 3.8.5 for anaconda distribution.

However, when I use command line in ST3 and run sys.version, it returns 3.3.6, which I think does not carry most packages that managed by anaconda, like pandas, numpy and so on. So when I editing my codes, I am used to type the package/module name, the press TAB to find what I need to complete the script, but it does not show any attributes or functions from the module while those keywords I've used in the script are still available.

Expected Behavior

For example, my script has

import pandas as pd
import numpy as np

x = np.array([[1, 1], [2, 2]])

I expect when I enter `x = np.' then press TAB, there should come a list of available functions/modules/attributes provided by the numpy package, as any other IDE would do. Now, it just doesn't, except for those I've used already in the script.

I've used ST3 before, and everything was fine then. Things get different when I downgrade my OS from Big Sur to Catalina, and I reinstall anaconda3 and Sublime Text3.

Anaconda or Miniconda version:
(base) mona@NaBookPro GoogleTrends % conda list anaconda
# packages in environment at /Users/mona/opt/anaconda3:
#
# Name                    Version                   Build  Channel
anaconda                  2020.11                  py38_0
anaconda-client           1.7.2                    py38_0
anaconda-navigator        1.10.0                   py38_0
anaconda-project          0.8.4                      py_0
Operating System:

OS Catalina

conda info
(base) mona@NaBookPro GoogleTrends % conda info

     active environment : base
    active env location : /Users/mona/opt/anaconda3
            shell level : 1
       user config file : /Users/mona/.condarc
 populated config files :
          conda version : 4.9.2
    conda-build version : 3.20.5
         python version : 3.8.5.final.0
       virtual packages : __osx=10.15.7=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /Users/mona/opt/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/mona/opt/anaconda3/pkgs
                          /Users/mona/.conda/pkgs
       envs directories : /Users/mona/opt/anaconda3/envs
                          /Users/mona/.conda/envs
               platform : osx-64
             user-agent : conda/4.9.2 requests/2.24.0 CPython/3.8.5 Darwin/19.6.0 OSX/10.15.7
                UID:GID : 501:20
             netrc file : None
           offline mode : False
neo2887 commented 3 years ago

When I use control(^) + ` in sublime text, calling the command line, and run sys.version, I get

>>> import sys
>>> sys.version
'3.3.6 (default, Mar 30 2018, 11:14:15) \n[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]'

Which is different from the python version I use in os command line and jupyter notebook.

neo2887 commented 3 years ago

What I get from terminal,

(base) mona@NaBookPro GoogleTrends % python3
Python 3.8.5 (default, Sep  4 2020, 02:22:02)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'3.8.5 (default, Sep  4 2020, 02:22:02) \n[Clang 10.0.0 ]'
neo2887 commented 3 years ago

I got error when I tried building import pandas as pd.

Traceback (most recent call last):
  File "/Users/mona/Dropbox/GoogleTrends/GGT_sorting.py", line 1, in <module>
    import pandas as pd
ImportError: No module named pandas
[Finished in 0.0s with exit code 1]
[cmd: ['python', '-u', '/Users/mona/Dropbox/GoogleTrends/GGT_sorting.py']]
[dir: /Users/mona/Dropbox/GoogleTrends]
[path: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

It is quite weird... since the build system worked fine before I start this issue. Before the issue, I set in anaconda Settings - user, "python_interpreter": "/Users/mona/opt/anaconda3/bin/python", then I set it to "python3" during editing the issue, and set it back to the path I used before. Then the error pops out...

csoja commented 3 years ago

It looks like Sublime Text is picking up your system python, instead of your Anaconda Python installation. The Anaconda Individual Edition documentation does have some examples of how to setup other IDEs to use their Anaconda installation and hopefully that will help you figure out how to configure it correctly for Anaconda. https://docs.anaconda.com/anaconda/user-guide/tasks/integration/sublime/

neo2887 commented 3 years ago

It looks like Sublime Text is picking up your system python, instead of your Anaconda Python installation. The Anaconda Individual Edition documentation does have some examples of how to setup other IDEs to use their Anaconda installation and hopefully that will help you figure out how to configure it correctly for Anaconda. https://docs.anaconda.com/anaconda/user-guide/tasks/integration/sublime/

Thank you csoja!

I followed their instruction exactly, and the problem still exists.

I've set "python_interpreter" to my local path: "/Users/mona/opt/anaconda3/bin/python" and it does not make a difference.