Hi everyone!
Kinda new to venvs. I've created one through Powershell and I activate with a .bat file, it works normally but it also seems to open the Activate.ps1 in my VS like a Notebook or txt file.
I can close or leave it and the program works fine but i don't know if this is Python/.bat/.ps1 error or even a normal behavior, but I don't want it opening, if possible.
After searching I found this post here: Typing venv scripts activate.ps1 open Notebook auto
But the post has 1 answer that does not solve my problem, and its a bit different since my program works fine even if this file auto opens
-using python 3.10.4
venv creation:
cd C:\Users\Me\Documents\DATA_SCIENCE\Projetos\Nome_Projeto\
python -m venv "C:\Users\Me\Documents\DATA_SCIENCE\Projetos\Nome_Projeto\Nome_do_Robo"
Nome_Projeto\Nome_do_Robo\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r "C:\Users\Me\Documents\DATA_SCIENCE\Projetos\_infos\Requirements\requirements_Robo.txt"
.bat file:
@echo off
setlocal
cd C:\Users\Me\Documents\DATA_SCIENCE\Projetos\Nome_Projeto\Nome_do_Robo\Scripts\
set PYTHONPATH=C:\Users\Me\Documents\DATA_SCIENCE\Projetos\Nome_Projeto\Nome_do_Robo\Scripts\
set pathLog=C:\Users\Me\Documents\DATA_SCIENCE\Projetos\_Logs\Nome_Projeto
.
.(Others string variables)
.
set resultado=C:\Users\Me\Documents\DATA_SCIENCE\Projetos\_Resultados_dos_Robos\Nome_Projeto\
taskkill /IM python.exe /F
C:\Users\Me\Documents\DATA_SCIENCE\Projetos\Nome_Projeto\Nome_do_Robo\Scripts\Activate.ps1 &
python C:\Users\Me\Documents\DATA_SCIENCE\Projetos\Nome_Projeto\ScrapStuff.py
I ran the .bat file in Powershell and VS Studio, both opens the following note (looks like a "how-to venv help" file)
(File is really long but if needed I paste the whole content)
<#
.Synopsis
Activate a Python virtual environment for the current PowerShell session.
.Description
Pushes the python executable for a virtual environment to the front of the
$Env:PATH environment variable and sets the prompt to signify that you are
in a Python virtual environment. Makes use of the command line switches as
well as the `pyvenv.cfg` file values present in the virtual environment.
.Parameter VenvDir
Path to the directory that contains the virtual environment to activate. The
default value for this is the parent of the directory that the Activate.ps1
script is located within.
.Parameter Prompt
The prompt prefix to display when this virtual environment is activated. By
default, this prompt is the name of the virtual environment folder (VenvDir)
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
.Example
Activate.ps1
Activates the Python virtual environment that contains the Activate.ps1 script.
.Example
Activate.ps1 -Verbose
Activates the Python virtual environment that contains the Activate.ps1 script,
and shows extra information about the activation as it executes.
.Example
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
Activates the Python virtual environment located in the specified location.
.Example
Activate.ps1 -Prompt "MyPython"
Activates the Python virtual environment that contains the Activate.ps1 script,
and prefixes the current prompt with the specified string (surrounded in
parentheses) while the virtual environment is active.
.Notes
On Windows, it may be required to enable this Activate.ps1 script by setting the
execution policy for the user. You can do this by issuing the following PowerShell
command:
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
For more information on Execution Policies:
https://go.microsoft.com/fwlink/?LinkID=135170
#>
Param(
[Parameter(Mandatory = $false)]
[String]
$VenvDir,
[Parameter(Mandatory = $false)]
[String]
$Prompt
)
<# Function declarations --------------------------------------------------- #>
I have 3 basic scripts that run in this venv, if needed i can share it also
Any help would be appreciated!
Thanks!
Deleted the venv and folder, restarted Desktop and re-created the entire venv in other folder.