My Env
$ uname -ro # returns: 4.17.9-200.fc28.x86_64 GNU/Linux
$ subl --version # returns: Sublime Text Build 3176
$ python --version # returns: Python 3.6.6
$ which python # returns:
# alias python='/usr/bin/python3'
# /usr/bin/python3
$ pip --version # returns: pip 10.0.1 from /home/<username>/.local/lib/python3.6/site-packages/pip (python 3.6)
$ which pip # returns:
# alias pip='/usr/bin/pip3'
# /usr/bin/pip3
$ echo $PATH # returns:
# /usr/share/Modules/bin:/usr/lib64/ccache:/home/<username>/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/<username>/.local/bin:/home/<username>/bin:/usr/local/cuda-9.0/bin:/home/<username>/workspaces/go/bin:/home/<username>/.cargo/:/home/<username>/.local/bin:/home/<username>/bin:/usr/local/cuda-9.0/bin:/home/<username>/workspaces/go/bin:/home/<username>/.cargo/:/home/<username>/.local/bin:/home/<username>/bin:/usr/local/cuda-9.0/bin:/home/<username>/.local/lib:/home/<username>/workspaces/go/bin:/home/<username>/.cargo/
# Running the following from inside sublime:
import sys
print(sys.executable)
returns:
/usr/bin/python3
[Finished in 0.0s]
My Problem
When I import user installed python libraries ST3 fails to import some, but not all libraries. For example:
A file containing the following:
import numpy
Returns:
[Finished in 0.2s]
A file containing:
import textblob
Returns:
Traceback (most recent call last):
File "/home/<username>/test.py", line 1, in <module>
import textblob
File "/home/<username>/.local/lib/python3.6/site-packages/textblob/__init__.py", line 2, in <module>
from .blob import TextBlob, Word, Sentence, Blobber, WordList
File "/home/<username>/.local/lib/python3.6/site-packages/textblob/blob.py", line 28, in <module>
import nltk
File "/home/<username>/.local/lib/python3.6/site-packages/nltk/__init__.py", line 114, in <module>
from nltk.collocations import *
File "/home/<username>/.local/lib/python3.6/site-packages/nltk/collocations.py", line 39, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
File "/home/<username>/.local/lib/python3.6/site-packages/nltk/metrics/__init__.py", line 16, in <module>
from nltk.metrics.scores import (accuracy, precision, recall, f_measure,
File "/home/<username>/.local/lib/python3.6/site-packages/nltk/metrics/scores.py", line 18, in <module>
from scipy.stats.stats import betai
File "/home/<username>/.local/lib/python3.6/site-packages/scipy/stats/__init__.py", line 345, in <module>
from .stats import *
File "/home/<username>/.local/lib/python3.6/site-packages/scipy/stats/stats.py", line 171, in <module>
from . import distributions
File "/home/<username>/.local/lib/python3.6/site-packages/scipy/stats/distributions.py", line 13, in <module>
from . import _continuous_distns
File "/home/<username>/.local/lib/python3.6/site-packages/scipy/stats/_continuous_distns.py", line 113, in <module>
class norm_gen(rv_continuous):
File "/home/<username>/.local/lib/python3.6/site-packages/scipy/stats/_continuous_distns.py", line 175, in norm_gen
`optimizer` argument is ignored.\n\n""")
File "/home/<username>/.local/lib/python3.6/site-packages/scipy/misc/doccer.py", line 159, in _doc
start_of_notes = cls_docstring.find(notes_header)
AttributeError: 'NoneType' object has no attribute 'find'
[Finished in 0.4s with exit code 1]
[shell_cmd: python3 -OO -u "/home/<username>/test.py"]
[dir: /home/<username>/]
[path: /usr/share/Modules/bin:/usr/lib64/ccache:/home/<username>/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/<username>/.local/bin:/home/<username>/bin:/usr/local/cuda-9.0/bin:/home/<username>/workspaces/go/bin:/home/<username>/.cargo/]
If I launch python from a terminal and import textblob the following returns:
>>> import textblob
>>>
What I think the problem may be:
Sublime is only seeing packages installed at the global level, not the user level.
In my first example I imported Numpy, which I installed with my distros packages manager.
$ sudo find / -name "numpy"
returns:
/usr/lib64/python3.6/site-packages/numpy
/usr/lib64/python3.6/site-packages/numpy/core/include/numpy
/usr/lib64/python2.7/site-packages/numpy
/usr/lib64/python2.7/site-packages/numpy/core/include/numpy
/usr/include/boost/python/numpy
/usr/include/numpy
In the second example I imported textblob. Textblob was installed with pip. The version of pip I have prompts users to use the --user flag when installing libraries.
$ sudo find / -name "textblob"
returns:
/home/<username>/.local/lib/python3.6/site-packages/textblob
Conclusion
The $PATH listed in the error message from sublime is not the same as $PATH in bash. I am not sure how to alter the $PATH in sublime or have it point to my $PATH defined in .bash_profile.
Additionally ST3 seems to be calling the -OO flag. When passing this flag in a bash environment I am able to recreate this error outside of ST3. Running without the flag operates as expected.
This problem persists across multiple work stations running the identical environment.
Any help would be greatly appreciated.