0

I am leaning programming now and get stuck in the very beginning.

I have sublime text 2 installed on my Mac, and I type some python code in and it runs. However, when I start to import module like pandas/matplotlib, it can not find those modules. Certainly I have used pip to install them.

So what is the solution please?

Victor
  • 659
  • 3
  • 8
  • 19

1 Answers1

0

Does Your code work with those modules when You use a different editor?

If it doesn't, Check if the modules You need are indeed installed. You can do this either by using the python prompt:

python
>>> help("modules")
>>> exit()

or using pip:

pip freeze

(sorry for posting this as an answer, but I'm currently not able to post comments)

  • thanks for your reply. Sublime Text 2 gives importError: No module named pandas, whereas when I type code in terminal in MAC, it doesn't complain – Victor Aug 23 '18 at 10:40
  • Checkout this post: https://stackoverflow.com/questions/27179268/pandas-installed-but-cannot-be-found-why-is-that. –  Aug 23 '18 at 10:56
  • I have created another build file, as my terminal is showing python 2.7.11 and sublime text 2 showing 2.7.10, but it doesn't help – Victor Aug 23 '18 at 12:18
  • did You try to change the PYTHONPATH variable like is suggested in the article above: Once Anaconda is installed, its Python distribution supercedes the Python distribution that ships with OS X. You've installed Pandas on the former distribution (or rather, it's come pre-installed), while Sublime Text is relying on the latter distribution to build and run. You'll want to modify Sublime Text to use the Python distribution from Anadonda. You can modify Python.sublime-settings as shown in https://stackoverflow.com/questions/8574919/sublime-text-2-custom-path-and-pythonpath –  Aug 23 '18 at 13:17