I’m trying to make a plugin but my python code needs some plugin like pandas to be installed in Python. By default the python that comes with the sublime doesn’t have it.
How can I install in ST’s python?
And can my plugin install this module automatically if somebody loads this plugin and pandas module is not present on their ST’s python?
My plugin requires support of other python module
Unfortunately it’s not on https://github.com/wbond/package_control_channel/blob/master/repository/dependencies.json. So that means you have to prepare following python modules by yourself:
- dateutil
- numpy
- pandas
- pytz
- six
!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!
Presuming your plugin depends on ST 4 with the py38 plugin host.
!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!
You are the only plugin user
Install Pandas into Lib/python38
will work.
The path of Lib/python38
can be obtained by executing
from pathlib import Path; str((Path(sublime.packages_path()) / '../Lib/python38').resolve())
in Sublime Text’s console.
To prepare modules, you can either
-
Do this manually. Go to pypi to download each module with
cp38
and the correct CPU architecture and decompress them intoLib/python38
. For example, this is the whole collection for Win64: https://www5.zippyshare.com/v/SN9G2ksb/file.html -
If you have Python 3.8 with pip installed on your local machine. You can just use pip to install modules into
Lib/python38
via$ python -m pip install -t=PATH_OF_LIB_PYTHON38 pandas
You want to make it for other people
You have 2 choices. Either of them are unlikely to happen.
-
Ask your user to go through steps described in
You are the only plugin user
. -
Vendor it.
-
Numpy
, which is compiled into native codes. That means you have to prepare various versions of your plugin depending on target CPU architectures. - This will make your plugin quite big. Maybe you don’t care though.
-
Eventually, you can do a quick test in Sublime Text’s console to check whether Pandas is usable.
>>> import pandas as pd
>>> pd.__version__
'1.5.3'