Unable to activate virtual environments on Windows 10 with Python 3.7 using cmd - python-3.x

I am having a problem with activating a virtual environment by the name FYP using cmd on Windows 10. I checked the bat file, which is of 1KB size.
See the below commands or image. It should have (FYP) on the start after running the activate.bat file.
C:\Users\Manish>M:
M:\>ENV\FYP\Scripts\activate.bat
M:\>
But using a similar command in PowerShell or VS code will get the environment activated.
Check the below image or command. It is showing (FYP) on the start of the command, and FYP env is now activated.
PS M:\> cd .\ENV\
PS M:\ENV> .\FYP\Scripts\activate
(FYP) PS M:\ENV> cd ..
(FYP) PS M:\> cd .\projects\
Earlier when I had Windows 7, the virtual environment was getting activated on both PowerShell and cmd as well. And I used similar commands in both cmd and PowerShell.
M:\ENV>FYP\Scripts\activate
But with Windows 10, I don't know why it is not getting activated on cmd.
Please help?
Is there any specific reason why the virtual environment is not activating.

The command line needs to know where to start. Add .\ to tell it that start in the current directory.
c:\Program Files (x86)>".\Internet Explorer\iexplore.exe"

So basically, I can easily activate it through Visual Studio Code's terminal(Powershell), using the command
<PATH_TO_VENV>\Scripts\activate
<PATH_TO_VENV>: where you have created the virtual environment.

Related

How to get powershell or pwsh exe file path in debian/linux

Need to run build script in both the environment (windows and Linux).Build script is pointing to the powershell.exe path in window environment and working fine. But at the same time, same build script is not getting the powershell path and throwing error.
Executing task in folder root: PowerShell /home/userName/FolderName/Assetmonitor/scripts/build/client/build-client-dev.ps1 <
The terminal process failed to launch: Path to shell executable "PowerShell" does not exist.
It sounds like your script is trying to call the PowerShell executable, but "powershell" (technically powershell.exe) only exists on Windows and is the executable for powershell 5.x and earlier. The executable for PowerShell 7, which is the only version I'm familiar with that's available on Linux, is named "pwsh"(pwsh.exe on Windows).
I would recommend either: 1) installing PowerShell 7 on your Windows boxes and changing the script to call for pwsh instead of "PowerShell" (remember that Linux is case-sensitive), or 2) creating a symbolic link to somewhere in your existing $PATH environment variable (like /usr/local/bin/) that points "PowerShell" to wherever your PowerShell 7 is installed on Linux.
The default path to the actual pwsh program, if you use the latest build files from Microsoft, is /opt/microsoft/powershell/7/pwsh, but that's already symlinked to /usr/bin/pwsh so you could link there instead:
sudo ln -s /opt/microsoft/powershell/7/pwsh /usr/local/bin/PowerShell

VBoxManage throwing VERR_ACCESS_DENIED error on Windows 10

I'm attempting to follow these instructions to set up OpenWrt on Virtual Box on Windows 10. I installed Virtual Box 6.1.4 on Windows 10. I configured my environment variables to have access to the VBox executables so I could run VBoxManage convertfromraw openwrt-15.05.1-x86-64-combined-ext4.img openwrt.vdi --format VDI. However, when I run that command (from Powershell or cmd, both of which I ran as an administrator), I get the following error:
Converting from raw image file="openwrt-15.05.1-x86-64-combined-ext4.img" to file="openwrt.vdi"...
VBoxManage.exe: error: Cannot open file "openwrt-15.05.1-x86-64-combined-ext4.img": VERR_ACCESS_DENIED
What can I do to get around this?
use 7zip to extract .gz file/
create a folder in Documents eg test
run cmd ad admin (right click run as administrator)
cd ....Documents\test (... your computer eg c:\users\john)
type command "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" convertfromraw --format VDI openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img openwrt.vdii
(with "" included exactly as I wrote)
and it's done.
I had the same problem and I found the solution on this video.
Seems a discompability in extraction.

How to change WebStorm enviroment settings for File Watcher?

I have simple File Watcher that run TSLint. If I copy the command and run it in the console all fine but WebStorm run it with old Node version and throw error Buffer.alloc is not a function.
I'm using nvm to manage node.js versions.
ubuntu 16.4
Different Node.js versions are on your $PATH when you start your script from the IDE and from terminal.
When being launched from desktop/System menu, WebStorm only sees environment variables configured in login shell, but not in interactive shell configuration files (like .bashrc or .zshrc).
Possible workarounds:
Workaround 1: make required variables available in a login shell by moving them to the corresponding shell profile config
Workaround 2: run IDE from a terminal, either with the command line launcher or with bin/webstorm.sh
Workaround 3: edit the desktop launcher and set command to /path/to/shell -l -i -c "/path/to/webstorm.sh" (make sure that the shell you specified there has the needed variables configured in its interactive shell configuration file)
see also https://youtrack.jetbrains.com/issue/IDEABKL-7589

How to activate python virtual environment in VS code terminal?

I have created a python virtual environment using VS code editor.
a virtual environment is created successfully but I am not able to activate it.
when I am trying to activate my virtual env
I have also tried with "activate.bat"
I was trying to activate virtual env command in PowerShell which is by default selected in VS Code, that why it was giving me an error.
we can select different terminal(PowerShell, Command Prompt, Git bash) in VS code. so I have just selected cmd(Command Prompt) and now it is working.
You are using Powershell in your terminal (as denoted by PS) in the begining of every line in the terminal. You can switch to cmd and it will work. To do this, check the above asnwer by Sandeep Bhatt. If the option is not available, follow these steps,
Open commands search (use Ctrl+Shift+P or from menu View->Command Palette...) while terminal is open
In command box that appears, type "Terminal: Select Default Shell" and select it.
All the available commands which are in path will be listed. Select command prompt here.
Once this is done, you can change into cmd by clicking the plus icon shown here
You need to change the shell like here in the picture
change it to git bash or terminal of windows, and use the command "source FolderNameOfVirtualenviremenrts/Scripts/activate" (this command is for git-bash terminal)
Assuming that you're using powershell and your python virtual environment is in the 'venv' folder then you'll need to source the Activate.ps1 script by using the following command
. .\venv\Scripts\activate.ps1
The dot (.) is the equivalent of "source" command in powershell.
After sourcing Activate.ps1 the virtual environment commands activate and deactivate will work.
With newer versions of virtual environments (https://github.com/microsoft/vscode-python/issues/6931) you can also activate the environment as in the following example:
& .\venv\Scripts\Activate.ps1
This should work now if you are in powershell:
.\Venv/Scripts/Activate.ps1
It's unclear what you're using to create the virtual environment, and I presume that you're simply accessing the terminal from VSCode.
Try source activate <env_name> to start your environment.

Showing error "nvmw command not found" when setting the path of nvmw in Nodejs

I am new in Nodejs. I want to install nvmw in my system. For that first I clone the respiratory using this command
git clone git://github.com/hakobera/nvmw.git "%HOMEDRIVE%%HOMEPATH%\.nvmw"
after that for activating nvmw, I used this command
set "PATH=%HOMEDRIVE%%HOMEPATH%\.nvmw;%PATH%"
in E drive.Folder is also created in E drive in name of %HOMEDRIVE%%HOMEPATH% and inside the folder all the datas and nvmw folder also created.
But after that when I am running this command nvmw help, it shows "nvmw command not found". I tried by changing the folder name also but it shows the same error. I think I am doing some mistake in setting the path.
In my case, that command is not working on Windows PowerShell.
The command for setting System Path should be run Windows Command Prompt.
In the other hands, you can add installed path with GUI.
For Windows PowerShell, see following question:
Setting Windows PowerShell path variable

Resources