Created
January 24, 2024 19:58
-
-
Save estevam5s/b1d1bb66aa31787a52bf8822bf5b3e9c to your computer and use it in GitHub Desktop.
Criando e ativando um ambiente em python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
class VirtualEnvManager: | |
def __init__(self, env_name='venv'): | |
self.env_name = env_name | |
def create_virtualenv(self): | |
try: | |
subprocess.check_call([sys.executable, "-m", "venv", self.env_name]) | |
print(f"Ambiente virtual '{self.env_name}' criado com sucesso.") | |
except subprocess.SubprocessError as e: | |
print(f"Erro ao criar o ambiente virtual: {e}") | |
if __name__ == "__main__": | |
manager = VirtualEnvManager("myenv") | |
manager.create_virtualenv() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
class VirtualEnvManager: | |
def __init__(self, env_name='venv'): | |
self.env_name = env_name | |
def create_virtualenv(self): | |
try: | |
subprocess.check_call([sys.executable, "-m", "venv", self.env_name]) | |
print(f"Ambiente virtual '{self.env_name}' criado com sucesso.") | |
except subprocess.SubprocessError as e: | |
print(f"Erro ao criar o ambiente virtual: {e}") | |
if __name__ == "__main__": | |
manager = VirtualEnvManager("myenv") | |
manager.create_virtualenv() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment