I’m trying to overcome a common error I see in several Python GUIs, including SublimeText 3.2.2—a Package Not Found Error. I’ve researched it extensively, and see a number of solutions suggested (some of them too vague to be useful, such as “you’ll need to modify the sys file”).
My goal: I want to work in SublimeText and to be able to use packages installed from different distributions (mainly via the commands “Conda install” and “pip install”) in the same Python project.
I’m hoping someone can tell me the right way to set my path (I believe that’s going to be the solution, but I’m a newb, so I don’t trust myself to know) so that that’s possible.
Conda installs packages here:
/Users/me/opt/anaconda3
Pip installs here (for 3.6; it installs in other directories, depending on the Python version):
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
When I run the following in Sublime:
**import sys**
**print sys.version**
I get this output:
/Users/me
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Library/Python/2.7/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
Question 1:
How should I modify my path to enable Sublime to find modules and packages install with either pip or conda?
Question 2:
Should I first change my interpreter in Sublime (because some of the packages I want to run will only work in Python 3.6 and higher)?
Question 3: Do I need to be running THAT interpreter when I make changes to my path?
Question 4: If I’m way off base–just dead wrong about even the general type of solution I’m considering–what’s the correct solution?
Further notes:
Some StackOverflow posts (and recommendations on other sites) say to modify the path so that the GUI can find the package. Others say never touch the path, create a virtual environment; or they say you don’t need a virtual environment, you need to write a new script … and so on. I’m too much of a novice to touch a path, without clearer instructions.
This is my error in SublimeText when I attempt to import bs4 for webscraping:
Traceback (most recent call last):
File “/Users/me/webscraping_beautifulsoup_prog_historian.py”, line 1, in
from bs4 import BeautifulSoup
ImportError: No module named bs4
bs4 is certainly on my harddrive, but I believe that the path followed by SublimeText doesn’t touch the directory bs4 is stored in (I’m on Mac Catalina OS10.15).
I’ve been trying different GUIs (PyCharm, Idle, Spyder …) to see which of them will allow me to import modules from different distributions; as I test the GUIs, I’m seeing this type of error frequently–“no module named …”
I think that if I finally understood how to resolve that error in different GUIs, I’d be able to make some serious headway in learning Python. I’ve been reading extensively about paths, and setting paths, and studying posts (here and elsewhere) about the import-module error, but I see so many variations of solutions I haven’t been able to choose among them (and feel safe about that choice).
Thanks for any help you can give me.