Git Product home page Git Product logo

sublime-text-virtualenv's Introduction

Sublime Text - Virtualenv

Manage your virtualenvs directly from Sublime Text 3.

Disclaimer: Not Maintained

I cannot maintain this project anymore since I stopped using Sublime Text. If you're interested on taking over reach out and we can discuss.

Features

  • Reusable build system. Execute code with a virtualenv without editing your paths manually.
  • Virtualenv search. Finds virtualenvs in the open folders or anywhere in your system.
  • Activation/Deactivation. Select or disable the current virtualenv easily.
  • Create and delete virtualenvs. With target python selection. Supports both the standard virtualenv package and the built-in venv module from Python 3.3.
  • Integration with other packages. SublimeREPL.

Support

Only Sublime Text 3. Tested in Linux and Windows but it should work in OS X as well.

Installation

Install through Package Control as usual:

  1. Open command palette through the menu or with Ctrl+Shift+P.
  2. Select Package Control: Install Package.
  3. Search Virtualenv and press enter.

Detailed instructions here.

Usage

Code Execution

Enable the Python + Virtualenv build system through the Tools -> Build System menu and execute with Ctrl+B. If you do not have any other custom Python builds defined, Automatic should work too.

The build system works with or without an activated virtualenv, so it can be used as default build for Python.

Activate

Search Virtualenv: Activate in the command palette and select the desired virtualenv.

Deactivate

The command Virtualenv: Deactivate is available when a virtualenv is activated.

Creating a virtualenv

Choose Virtualenv: New (or Virtualenv: New (venv) for built-in virtualenv), type a destination path and select a python binary. The new virtualenv will be activated automatically.

Deleting a virtualenv

Use the command Virtualenv: Remove, choose a virtualenv and confirm.

Integrations

Launch a Python REPL using the current virtualenv with the command Virtualenv: SublimeREPL - Python.

Settings

The list of default settings is available through Preferences -> Package Settings -> Virtualenv -> Default. Do not modify the default settings as you will lose all the changes if the package is updated. You should override the necessary settings in Package Settings -> Virtualenv -> User instead.

executable

The executable used for virtualenv creation. Defaults to python -m virtualenv, assuming that virtualenv is installed on the default python prefix. Depending on your setup you might want to change this to something like: virtualenv, virtualenv-3.3, python3 -m virtualenv, etc.

virtualenv_directories

A list of directory paths searched for virtualenvs. By default, includes virtualenvwrapper's WORKON_HOME. ~/.virtualenvs in Linux and OS X, and ~\Envs in Windows (virtualenvwrapper-win).

There is a shortcut command for quickly adding a virtualenv directory to your settings: Virtualenv: Add directory.

extra_paths

Additional paths searched for python binaries. It might be useful in case of portable python installations. Defaults to none.

Advanced

The current virtualenv path is stored in the project settings and can be edited manually if the project has been saved to a *.sublime-project file.

Extending or customizing the build system should be possible. Just set "target": "virtualenv_exec" in your build system definition, or import and inherit from Virtualenv.commands.VirtualenvExecCommand. More information on Sublime Text's build systems here.

Future plans

Just some ideas for possible improvements.

  • Integration with more packages. Paths for SublimeCodeIntel?
  • Brother package for pip commands.

sublime-text-virtualenv's People

Contributors

adrianlc avatar snaily avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sublime-text-virtualenv's Issues

Can't find egg-linked development module

I'm developing a Python package (in Windows) which is linked to my global site-packages with the usual setup.py develop. When I activate the virtualenv using the plugin and try to import mymodule I get an ImportError. Other locally installed packages (i.e. not egg-linked) work fine.

I thought this might be an issue with my virtualenv, but if I activate it from a command prompt and open a Python shell I can import my module without any issues. It seems like there's an problem with Sublime not recognizing egg-linked modules -- is there some workaround for this?

Many thanks

No Virtualenv upon ST3 upgrade build 3176

I recently upgraded to ST3 3176. When I browse packages, virtualenv is not there. when I search to install or select activate, it does not come up. Is this just me, or is there a problem with your app and the upgrade? Is there a fix? Thanks.

how to automatically enter into virtualenv-python2.7 without manually activate?Thanks

Sorry to interrupt.
Could you tell me how to automatically enter virtualenv without manually activate?
I want an effect like this:
①double click a xx.py file and enter into sublime
②without manual activate the virtualenv,it already enter into python2.7 of virtualenv
③if I want to change to virtualenv-python3.5,I can use shift+ctrl+p->activate->python3.5

Why I want this effect?
Because in my .bashrc ,I added the following 3 lines
**alias py2.7="source /home/appleyuchi/.virtualenvs/python2.7/bin/activate&&deactivate&&source /home/appleyuchi/.virtualenvs/python2.7/bin/activate"

alias py3.5="source /home/appleyuchi/.virtualenvs/python3.5/bin/activate&&deactivate&&source /home/appleyuchi/.virtualenvs/python3.5/bin/activate"
py2.7**

So,dear sir ,does sublime-text-virtualenv has similar settings?
Thanks very much .
if i lauch sublime in terminal already in virtualenv-python2.7,then I cannot use sublime-text-virtualenv to change to python3.5,so this is not a good solution.
Many Thanks again

It seems not working on Mac OS

I have tried the latest version on Mac OS, but I still cannot build my project properly using virtualenv. In my virtualenv I used Python 3.5, but when I used python + virtualenv to build, it used Python 2.9.

When I do virtualenv : activate, I didn't get anything and the building still does not work.

Any suggestions?

Lists duplicate or more venvs when activating

I'm running ST3 build 3114 with the virtualenv package. I added 3 venvs using the directory add option. Later on I deleted those venvs and recreated them, re-adding the directory. Now after this when I attempt to Activate one of the venvs, it lists 6, 2 sets of 3s. Then I re-added the venvs from the directory and now it shows 9, 3 sets of 3s. I can't delete one of the options as it will delete the venv i created. But if I do delete it, then it's removed from all 3 sets. Here is a screenshot I hope can explain it better: http://i.imgur.com/KOiOYkK.png

Support virtualenv inside project directories

I generally have the habit to put my virtualenvs inside each project directory, and I use direnv to generate and activate my virtualenv automatically inside the project directory in the terminal.

However, this workflow seems not supported by this plugin: I can't find a way to specify in "virtualenv_directories" to search in the current project directory.

Is this possible currently?
If not, can this be added?

ImportError with locally defined modules

I use this plugin with SublimeREPL and have had no problems until now. However, I'm just now trying to import a locally defined module within SublimeREPL + virtualenv, and I'm getting an ImportError.

Here's my folder structure (main.py tries to import a Class defined in utilities.py):

folder/
main.py
utilities.py
init.py

If I use SublimeREPL with no virtualenv, I can successfully import the module.
If I use bash and activate the virtualenv from there, and then open up a Python shell, I can also successfully import the module.

Any ideas? Thanks!

Activating a virtual environment in Windows doesn't change the build system

I have Anaconda installed with Python 2.7 on Windows 10, and I created a virtual environment that uses Python 3.5. If I activate the Python 3.5 virtual environment within SublimeText and run the following code

import sys print(sys.version)

I get the following output

2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)]

which is obviously not Python 3.5. Opening a command prompt, activating my Python 3.5 virtual environment, and executing the same code yields

3.5.3 |Anaconda 4.4.0 (64-bit)| (default, May 15 2017, 10:43:23) [MSC v.1900 64 bit (AMD64)]

Additionally, I've saved the Sublime Project to see if it's setting the virtual environment correctly, and it appears to be

"virtualenv": "C:\\Users\\My Name\\Anaconda2\\envs\\python3env"

What might be prohibiting my SublimeText installation from building with the alternative environment?

UTF-8 Local Issue on Mac

Hi,
When running this on a Mac I get a UTF-8 local error.

When running scripts through the terminal:

source venv/bin/activate
python test.py

I am able to resolve the issue by editing the ~./bash_profile and adding two lines -
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Issue executing postactivate script when using a virtualenv

postactivate seems to not be loaded.

To test it I added a path to $PYTHONPATH:

export OLD_PYTHONPATH="$PYTHONPATH"

if [ -z $PYTHONPATH ]; then
    export PYTHONPATH=/home/bsemene/dev/logging_handlers
else
    export PYTHONPATH=$PYTHONPATH:/home/bsemene/dev/logging_handlers
fi

On the console I execute the following in my virtualenv:

$python -c "import sys ; import os ; print os.getenv('PYTHONPATH') in sys.path"
True

And on sublime (after activating the virtualenv):
print '/home/bsemene/dev/logging_handlers' in sys.path returns False

ST4 does not load Default into the Python 3.3 environment any longer

import Default as sublime_default

Tried with ST4 and got the following in the console

Packages/Virtualenv.sublime-package/commands.py", line 126, in <module>
AttributeError: 'module' object has no attribute 'exec'

To get this package working in ST4 I unzipped the package, created a file in the root of this package called .python-version with the contents of 3.8, and zipped it up. Now working and backwards compatible with ST2 and ST3. Will submit a PR.

cancel build

When running a python file using the virtualenv package, it is not possible to cancel the build using the 'Cancel Build' button located in Tools tab

Doesn't load correct python on Mac OS X

Hi there,

I was hoping this might be the easy answer to my problems of deal with virtualenvs within ST3. I followed all the instructions and it doesn't seem to work on Mac OS. When I try to activate a virtualenv from the command palette, it correctly lists the environments. There don't seem to be any issues with running the activate command; however even when I choose the Python + Virtualenv build system specifically, it doens't seem to run python within the activated environment.

Any suggestions as to how to diagnose the issues? Would be great to get this working.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.