Installing numpy for Sublime Text 3

删除回忆录丶 提交于 2021-01-04 05:57:47

问题


I'm using Sublime Text 3 on Ubuntu 14.04, and I'm just warming up to Package Management in Sublime. I came across this plugin Advanced CSV and installed it via Package Control but it says it requires the numPy library installed "in the packages folder". Now I'm a little confused as to what that means and I've found a number of similar questions but it was with respect to plugin development hence I didn't really understand them.

My question is do I achieve this by a standard installation of a Python library such as numPy after extracting the folder numpy-1.11.0 to /home/{username}/.config/sublime-text-3/Packages/ or is it some other technique with respect to building or adding the dependency to a config file ?


回答1:


Julien Salinas' answer covers some of the broad strokes, but not the correct details. You can't just download numpy-1.11.0.tar.gz from PyPI and extract it into Packages/numpy. It needs to be built by running setup.py, and the annoying thing is that it needs to be built using Python 3.3, which you may or may not have already installed on your system. The reason for this is 3.3 is the version of Python that ST3 uses internally, and since plugins run (in most cases) using Sublime's interpreter, any compiled modules need to be built with the same major.minor version of that interpreter (the major.minor.micro version shouldn't make a difference).

Assuming you don't, you'll have to download Python-3.3.6.tgz (MD5 checksum here) from python.org and build it yourself. This is fairly straightforward if you're used to building programs from source on Linux, but in order to get all the modules built (it'll say at the end of the make run what modules weren't built) you'll most likely need to install some external libraries.

Once you get 3.3.6 built and installed (I'd recommend a custom location so there's no chance of it interfering with the system version(s) of Python), extract the numpy archive to a custom location and build it with setup.py using Python 3.3.6. Again, you may need some external libraries to successfully build it. Once it's built, install it to Python 3.3.6's site-packages directory, then finally you can copy the numpy folder from site-packages to ~/.config/sublime-text-3/Packages. Note the capitalization (or lack thereof) - the final directory should be Packages/numpy, not Packages/Numpy as indicated in the other answer. Once properly installed, restart Sublime and the Advanced CSV plugin should function as expected.

Good luck!




回答2:


Use the existing SublimeText dependency:

sublime-numpy

 

 

Resources:

  • dependencies documentation
  • full list of SublimeText dependencies



回答3:


As stated in the doc (https://github.com/wadetb/Sublime-Text-Advanced-CSV), you can either use numpy or Tiny Numpy. If Tiny Numpy is enough, then there is nothing to do since it is already included in the Advanced CSV installation folder.

If you really need Numpy - which can be tough to install - then download it and install it in a newly created sublime text package folder: ~/.config/sublime-text-3/Packages/numpy

This post explains you how precisely : Sublime Plugin: How can I import wx? Basically the trick is to import the package properly in your python file. Let's say you downloaded and installed numpy in this folder: ~/.config/sublime-text-3/Packages/numpy If you want to use ipmt function, then you should import it this way :

from .numpy import ipmt


来源:https://stackoverflow.com/questions/36603963/installing-numpy-for-sublime-text-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!