Search code examples
pythonpython-3.xsublimetext3virtualenvsublime-text-plugin

How to install additional python libraries such as "bs4" or "Tensorflow" for SublimeText "virtualenv" package?


I use SublimeText for programming in python - it's easy and to build a program I have to just press Ctrl+b. To use additional libraries such as "requests" or "tensorflow" I've installed "VirtualEnv" package for SublimeText https://packagecontrol.io/packages/Virtualenv. I tried to use source /... my path.../activate, but instead of activation there is different python versions

suleyman@Linuxoid:~/.virtualenvs/bin$ ls
python  python3  python3.6

And i can't use pip install bs4 (for example) to install additional python's libraries. So, how to install python's libraries in SublimeText's "virtual environment" package? Thank you


Solution

  • SublimeText itself doesn't install Python packages. Instead, the virtualenv package substitutes a Python binary that you specify instead of the system installation whenever you hit Ctrl+B. Your virtual environments are stored in the ~/.virtualenvs directory (though you can keep them anywhere). From your snippet above, it appears you have three virtualenvs installed, called python, python3 and python3.6.

    To install TensorFlow or Requests, you need to activate your virtualenv from the terminal:

    source ~/.virtualenvs/python3.6/bin/activate
    

    Then run your installation commands:

    pip install tensorflow
    

    You can verify the installation completed successfully by running pip freeze.

    In sublime, check the virtualenv package settings to confirm that it's pointed at your ~/.virtualenvs directory. When you run the command to select a virtualenv (Ctrl+Shift+P), you will see a list of all the virtualenvs saved to that folder. If you select the python3.6 environment, you can now use Tensorflow.