I want to create a virtualenv in Windows 10 for python 3.7
I'm trying to follow the instruction from python doc
So first I entered the command
PS T:\python -m venv c:\path\to\myenv
it did create directories and files into that path
then according to the documentation, using PowerShell I entered:
PS T:\path\to\myenv\Scripts\Activate.ps1
but I got the following:
The term
'T:\path\to\myenv\Scripts\Activate.ps1' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ T:\path\to\myenv\Scripts\Activate.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (T:\path\to\myenv...ts\Activate.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
What am I missing
you should replace
path\to\myenv
to your actual path
so as said in docs
C:\> <venv>\Scripts\Activate.ps1
for example it should be something like
C:\>MyProjectsFolder\first_project\venv\Scripts\Activate.ps1
the other workaround is to manually change directories to Scripts folder and then run
Activate.ps1
if it didnt solve your problem please specify your project folder and structure
Related
Whenever I type django-admin start project project name the console returns Django-admin : The term 'Django-admin' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
Django-admin start project emart
+ CategoryInfo : ObjectNotFound: (Django-admin:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException.
The correct syntax is $ django-admin startproject mysite
Also, make sure to have the Python envirovment you want to use (the one with Django installed) active
Check the official documentation for Django
I had everything working fine, then out of nowhere I keep getting this
PS C:\Users\rygra\Documents\Ryan Projects\totalwine-product-details-scraper> ensurepip
ensurepip : The term 'ensurepip' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ensurepip
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (ensurepip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\rygra\Documents\Ryan Projects\totalwine-product-details-scraper> py get-pip.py
C:\Users\rygra\AppData\Local\Programs\Python\Python310\python.exe: can't open file 'C:\\Users\\rygra\\Documents\\Ryan Projects\\totalwine-product-details-scraper\\get-pip.py': [Errno 2] No such file or directory
PS C:\Users\rygra\Documents\Ryan Projects\totalwine-product-details-scraper>
How do I resolve this issue?
Go to control panel > Programs > Programs and features > search python and right click and click the change button > choose to modify > Make sure to tick this one:
It looks like you're on Windows.
As described in https://pip.pypa.io/en/stable/installation/#ensurepip, you should run:
py -m ensurepip --upgrade
You can make a virtual environment with
python3 -m venv venv or python -m venv venv in case the first doesn't work.
Then, open the folder "Scripts" inside of the created venv's folder and copy the files with "pip" in their name.
Finally, paste those files on the "Scripts" folder of your original python folder (the one you had installed on your computer before).
I have downloaded vs code in my windows 10 computer just, I want to learn python in it.
So, I have installed some extensions like "Python" , "Python
for VSCode" ,"code runner".
But when I click on the run button (Ctrl+ALT+N)
I am getting this error in my terminal:
python : The term 'python' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python -u "e:\C File\Source file\practice.py"
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
But when I type py -u "e:\C File\Source file\practice.py"
instead of python -u "e:\C File\Source file\practice.py"
it is working,
Now what should I do to run this at one mouse click, I don't want to run the code by typing the command.
IMHO, most likely your 'Python' global environment variable is not set correctly.
But, since you mention that py -u [File Path] command seems to give you the output I can suggest that you change how "Code Runner" extension sends a Run command.
Steps:
Click File>Preferences>Settings (shortcut Ctrl+,)
Open "settings.json" file (refer to my attached GIF file for reference)
Paste the following code lines at the end of this file ensuring you don't miss any commas (again refer to the attached GIF):
"code-runner.executorMap": {
"python": "py -u",
},
This should change how the Code-Runner extension sends the Run Code command for Python files. Save the settings.json file and try running your code again using the same shortcut Ctrl+Alt+N".
Does this fix your issue, Pranav? If not, maybe post a clipping of the error message again.
Link to the GIF file showing how to insert the code in settings.json file
I'm trying to run 'pipenv' on Windows 10, and it doesn't want to run... The error is receive is below
PS C:\Users\charl\Documents\Python\Face Recognition> pipenv shell
pipenv : The term 'pipenv' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ pipenv shell
+ ~~~~~~
+ FullyQualifiedErrorId : CommandNotFoundException```
Use python -m pipenv instead of just pipenv, it should work. Best of luck to you.
I've been having this issue on my new laptop for a couple of hours and cannot figure out what's causing it. I'm trying to install scikit-learn with conda and get the following error
conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ conda install -c anaconda scikit-learn
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (conda:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Has anybody else had a similar issue on Windows 10?
Have you already activated the environment for this use case?
There is a long running thread about this on the GitHub conda discussion regarding conda failures various Windows 7 and higher, here:
https://github.com/conda/conda/issues/626
One suggestion is:
The down and dirty:
Check to see if activate works in cmd.exe.
If doesn't work or not acceptable--as #TurboTim shows:
Powershell needs the path to each env (anaconda3\envs\someenv\py33.exe. Laborious! :p
If you don't mind polluting your powershell a little, you can create a profile script which is run every time you open powershell.
The below will add the functions Invoke-CmdScript, Conda-Activate, Conda-Deactivate to your powershell. See Tim's link above for why.
PS C:> New-Item -Path $profile -ItemType File -Force
This creates a script at:
PS C:\> echo $profile
...something like C:\Users\yourUser\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Edit that script.
PS C:\> explorer $profile
Add this code, save, and reopen powershell (or . $profile ) :
function Invoke-CmdScript {
param(
[String] $scriptName
)
$cmdLine = """$scriptName"" $args & set"
& $Env:SystemRoot\system32\cmd.exe /c $cmdLine |
Select-String '^([^=]*)=(.*)$' | ForEach-Object {
$varName = $_.Matches[0].Groups[1].Value
$varValue = $_.Matches[0].Groups[2].Value
Set-Item Env:$varName $varValue
}
}
$condaRoot = "$Env:USERPROFILE\Anaconda3"
function Conda-Activate([string]$condaEnv) {Invoke-CmdScript $condaRoot\Scripts\activate.bat $condaEnv}
function Conda-Deactivate {Invoke-CmdScript $condaRoot\Scripts\deactivate.bat}
Usage:
C:\> Conda-Activate TFTheano
C:\> Conda-Activate root
C:\> conda info --envs
Disclaimers: Deactivate, as written, didn't do the job for me, thus I just use Conda-Activate to move around. Also,
I don't suspect there are security cautions with adding Invoke-Cmd to profile, so please chime in if 2 cents
I found this online: Unblock-File -Path .\Get-RemoteProgram.ps1
I'm going to try that command in power shell as soon as I can.
I previously had Python installed before conda and since having both together is said to be bring complications I uninstalled the original Python interpreter. This is what worked for me when the same error came up while trying to run a python script using conda.
TLDR; Simply add the path of conda.exe to the environment variables.