# eric7.VirtualEnv.VirtualenvManager

Module implementing a class to manage Python virtual environments.

### Global Attributes

None

### Classes

VirtualenvManager | Class implementing an object to manage Python virtual environments.

### Functions

None

## VirtualenvManager

Class implementing an object to manage Python virtual environments.

### Signals

virtualEnvironmentAdded()
  emitted to indicate the addition of a virtual environment
virtualEnvironmentChanged(name)
  emitted to indicate a change of a virtual environment
virtualEnvironmentRemoved()
  emitted to indicate the removal and deletion of a virtual environment
virtualEnvironmentsListChanged()
  emitted to indicate a change of the list of virtual environments (may be used to refresh the list)

### Derived from

QObject

### Class Attributes

DefaultKey

### Class Methods

None

### Methods

VirtualenvManager | Constructor
__isEnvironmentDeleteable | Private method to check, if a virtual environment can be deleted from disk.
__loadSettings | Private slot to load the virtual environments.
__saveSettings | Private slot to save the virtual environments.
addVirtualEnv | Public method to add a virtual environment.
createVirtualEnv | Public slot to create a new virtual environment.
deleteVirtualEnvs | Public method to delete virtual environments from the list and disk.
environmentForInterpreter | Public method to get the environment a given interpreter belongs to.
getDefaultEnvironment | Public method to get the default virtual environment.
getEnvironmentEntries | Public method to get a dictionary containing the defined virtual environment entries.
getVirtualEnvironmentsBaseDir | Public method to set the base directory for the virtual environments.
getVirtualenvDirectory | Public method to get the directory of a virtual environment.
getVirtualenvExecPath | Public method to get the search path prefix of a virtual environment.
getVirtualenvInterpreter | Public method to get the interpreter for a virtual environment.
getVirtualenvNames | Public method to get a list of defined virtual environments.
isCondaEnvironment | Public method to test, if a given environment is an Anaconda environment.
isGlobalEnvironment | Public method to test, if a given environment is a global one.
isRemoteEnvironment | Public method to test, if a given environment is a remotely accessed environment.
isUnique | Public method to check, if the give logical name is unique.
reloadSettings | Public slot to reload the virtual environments.
removeVirtualEnvs | Public method to delete virtual environment from the list.
renameVirtualEnv | Public method to substitute a virtual environment entry with a new name.
setVirtualEnv | Public method to change a virtual environment.
setVirtualEnvInterpreter | Public method to change the interpreter for a virtual environment.
setVirtualEnvironmentsBaseDir | Public method to set the base directory for the virtual environments.
showVirtualenvManagerDialog | Public slot to show the virtual environment manager dialog.
upgradeVirtualEnv | Public slot to upgrade a virtual environment.

### Static Methods

None

#### VirtualenvManager (Constructor)

VirtualenvManager(parent=None)

Constructor

parent (QWidget)
  reference to the parent object

#### VirtualenvManager.__isEnvironmentDeleteable

__isEnvironmentDeleteable(venvName)

Private method to check, if a virtual environment can be deleted from disk.

venvName (str)
  name of the virtual environment

Return:
  flag indicating it can be deleted

Return Type:
  bool

#### VirtualenvManager.__loadSettings

__loadSettings()

Private slot to load the virtual environments.

#### VirtualenvManager.__saveSettings

__saveSettings()

Private slot to save the virtual environments.

#### VirtualenvManager.addVirtualEnv

addVirtualEnv(venvName, venvDirectory, venvInterpreter="", isGlobal=False, isConda=False, isRemote=False, execPath="", )

Public method to add a virtual environment.

venvName (str)
  logical name for the virtual environment
venvDirectory (str)
  directory of the virtual environment
venvInterpreter (str)
  interpreter of the virtual environment
isGlobal (bool)
  flag indicating a global environment
isConda (bool)
  flag indicating an Anaconda virtual environment
isRemote (bool)
  flag indicating a remotely accessed environment
execPath (str)
  search path string to be prepended to the PATH environment variable

#### VirtualenvManager.createVirtualEnv

createVirtualEnv(baseDir="")

Public slot to create a new virtual environment.

baseDir (str)
  base directory for the virtual environments

#### VirtualenvManager.deleteVirtualEnvs

deleteVirtualEnvs(venvNames)

Public method to delete virtual environments from the list and disk.

venvNames (list of str)
  list of logical names for the virtual environments

#### VirtualenvManager.environmentForInterpreter

environmentForInterpreter(interpreter)

Public method to get the environment a given interpreter belongs to.

interpreter (str)
  path of the interpreter

Return:
  tuple containing the environment name and a dictionary containing a copy of the default virtual environment

Return Type:
  tuple of (str, dict)

#### VirtualenvManager.getDefaultEnvironment

getDefaultEnvironment()

Public method to get the default virtual environment.

Default is an environment with the key '' or the first one having an interpreter matching sys.executable (i.e. the one used to execute eric with)

Return:
  tuple containing the environment name and a dictionary containing a copy of the default virtual environment

Return Type:
  tuple of (str, dict)

#### VirtualenvManager.getEnvironmentEntries

getEnvironmentEntries()

Public method to get a dictionary containing the defined virtual environment entries.

Return:
  dictionary containing a copy of the defined virtual environments

Return Type:
  dict

#### VirtualenvManager.getVirtualEnvironmentsBaseDir

getVirtualEnvironmentsBaseDir()

Public method to set the base directory for the virtual environments.

Return:
  base directory for the virtual environments

Return Type:
  str

#### VirtualenvManager.getVirtualenvDirectory

getVirtualenvDirectory(venvName)

Public method to get the directory of a virtual environment.

venvName (str)
  logical name for the virtual environment

Return:
  directory path

Return Type:
  str

#### VirtualenvManager.getVirtualenvExecPath

getVirtualenvExecPath(venvName)

Public method to get the search path prefix of a virtual environment.

venvName (str)
  logical name for the virtual environment

Return:
  search path prefix

Return Type:
  str

#### VirtualenvManager.getVirtualenvInterpreter

getVirtualenvInterpreter(venvName)

Public method to get the interpreter for a virtual environment.

venvName (str)
  logical name for the virtual environment

Return:
  interpreter path

Return Type:
  str

#### VirtualenvManager.getVirtualenvNames

getVirtualenvNames(noRemote=False, noConda=False)

Public method to get a list of defined virtual environments.

noRemote (bool)
  flag indicating to exclude environments for remote debugging
noConda (bool)
  flag indicating to exclude Conda environments

Return:
  list of defined virtual environments

Return Type:
  list of str

#### VirtualenvManager.isCondaEnvironment

isCondaEnvironment(venvName)

Public method to test, if a given environment is an Anaconda environment.

venvName (str)
  logical name of the virtual environment

Return:
  flag indicating an Anaconda environment

Return Type:
  bool

#### VirtualenvManager.isGlobalEnvironment

isGlobalEnvironment(venvName)

Public method to test, if a given environment is a global one.

venvName (str)
  logical name of the virtual environment

Return:
  flag indicating a global environment

Return Type:
  bool

#### VirtualenvManager.isRemoteEnvironment

isRemoteEnvironment(venvName)

Public method to test, if a given environment is a remotely accessed environment.

venvName (str)
  logical name of the virtual environment

Return:
  flag indicating a remotely accessed environment

Return Type:
  bool

#### VirtualenvManager.isUnique

isUnique(venvName)

Public method to check, if the give logical name is unique.

venvName (str)
  logical name for the virtual environment

Return:
  flag indicating uniqueness

Return Type:
  bool

#### VirtualenvManager.reloadSettings

reloadSettings()

Public slot to reload the virtual environments.

#### VirtualenvManager.removeVirtualEnvs

removeVirtualEnvs(venvNames)

Public method to delete virtual environment from the list.

venvNames (list of str)
  list of logical names for the virtual environments

#### VirtualenvManager.renameVirtualEnv

renameVirtualEnv(oldVenvName, venvName, venvDirectory, venvInterpreter, isGlobal, isConda, isRemote, execPath, )

Public method to substitute a virtual environment entry with a new name.

oldVenvName (str)
  old name of the virtual environment
venvName (str)
  logical name for the virtual environment
venvDirectory (str)
  directory of the virtual environment
venvInterpreter (str)
  interpreter of the virtual environment
isGlobal (bool)
  flag indicating a global environment
isConda (bool)
  flag indicating an Anaconda virtual environment
isRemote (bool)
  flag indicating a remotely accessed environment
execPath (str)
  search path string to be prepended to the PATH environment variable

#### VirtualenvManager.setVirtualEnv

setVirtualEnv(venvName, venvDirectory, venvInterpreter, isGlobal, isConda, isRemote, execPath, )

Public method to change a virtual environment.

venvName (str)
  logical name of the virtual environment
venvDirectory (str)
  directory of the virtual environment
venvInterpreter (str)
  interpreter of the virtual environment
isGlobal (bool)
  flag indicating a global environment
isConda (bool)
  flag indicating an Anaconda virtual environment
isRemote (bool)
  flag indicating a remotely accessed environment
execPath (str)
  search path string to be prepended to the PATH environment variable

#### VirtualenvManager.setVirtualEnvInterpreter

setVirtualEnvInterpreter(venvName, venvInterpreter)

Public method to change the interpreter for a virtual environment.

venvName (str)
  logical name for the virtual environment
venvInterpreter (str)
  interpreter path to be set

#### VirtualenvManager.setVirtualEnvironmentsBaseDir

setVirtualEnvironmentsBaseDir(baseDir)

Public method to set the base directory for the virtual environments.

baseDir (str)
  base directory for the virtual environments

#### VirtualenvManager.showVirtualenvManagerDialog

showVirtualenvManagerDialog(modal=False)

Public slot to show the virtual environment manager dialog.

modal
  flag indicating that the dialog should be shown in a blocking mode

#### VirtualenvManager.upgradeVirtualEnv

upgradeVirtualEnv(venvName)

Public slot to upgrade a virtual environment.

venvName (str)
  name of the virtual environment

Up