how can i solve this issue? - python

'\env\Scripts\activate.bat : The term '\env\Scripts\activate.bat'
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 \env\Scripts\activate.bat
CategoryInfo : ObjectNotFound: (\env\Scripts\activ
ate.bat:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException'

I'm going to make a few assumptions, if they're wrong you can let me know.
You are on windows (because you are running a batch file) and you are running this in vs code's terminal.
Try just typing env\Scripts\activate.
This is because .bat files run in the windows command prompt, but vs code's terminal is PowerShell which doesn't recognize batch files (PowerShell uses .ps1 files).

Related

The command source sandbox/bin/activate doesn't work in powershell

I just start the course "Building Neo4j Applications with Python" in Neo4j Graph Academy. In the course I created a virtual environment named sandbox with python -m venv sandbox but when I want to activate with the code indicated in the course: source sandbox/bin/activate the powershell console shows this error:
source : The term 'source' is not recognized as the name of a cmdlet, function, script file.
script or executable program. Check if you spelled the name correctly, or if you included a
path, check that the path is correct and try again.
On line: 1 Character: 1
+ source sandbox/bin/activate
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (source:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This looks like you are on Windows, using PowerShell, and trying to activate the virtual environment with the bash/zsh script meant for Unix systems.
Instead, try running
sandbox\Scripts\Activate.ps1
You can find the full documentation with more details and things to consider here: https://docs.python.org/3/library/venv.html
Make sure to give it a good read.

env : The term 'env' is not recognized as the name

I am new to coding and I am learning about environment variables in python using pycharm. I am trying to hide my API KEY in the terminal for basic security however when I type env into the terminal this is the response.
env : The term 'env' 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
env
+ CategoryInfo : ObjectNotFound: (env:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
How can I fix this? How can I fix the path or find the path?
env is not a program installed by default on Windows, you're probably thinking of the env command commonly used on Linux and Unix based systems to display your environment. The equivalent Windows command is Get-ChildItem Env: for PowerShell, and SET in command prompt (Thanks #ᴓᴓᴓ!)

The term 'auto-py-to-exe' is not recognized error while converting the .py file to .exe

After I finish my python project, I tried to convert it to .exe file, so I use python version 3.10. I already installed the auto-py-to-exe app from the cmd but when I want to open it I get this error:
auto-py-to-exe : The term 'auto-py-to-exe' 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
+ auto-py-to-exe
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (auto-py-to-exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Check if you added Python and Python Scripts to your PATH.
Search for "Edit the system environment variables" (Windows Search) and click the first result
Click "Environment Variables..." in the window that opened
In the "System variables" section double click the "Path" variable
In the window that opened click the "New" button and type C:\Python310\ there. Create another entry and type C:\Python310\Scripts\ there.
Click "OK"
Now open the command prompt (make sure to not open the terminal) and type in auto-py-to-exe or autopytoexe, both should work.

jupyter is not runing even after installation

jupyter is install but still it shows this
> jupyter notebook
jupyter : The term 'jupyter' 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
jupyter notebook
+ CategoryInfo : ObjectNotFound: (jupyter:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Assuming you are using windows, Jupyter can be opened via your start menu and will open in a chrome tab.

How to modify Start Without Debugger script for python in MS Visual Studio Code

I recently installed MS Visual Studio Code for the first time (we'll be using it on an upcoming project). I wrote a simple Hello, World program in python and clicked Debug > Start Without Debugging. MSVSC runs the program just fine, but after that it runs a couple more commands, one of which generates an error (see below). These commands are unnecessary and the error is ugly and distracting.
Where is the script that MSVSC is running? I want to remove those two useless lines.
PS C:\Users\me> cd 'c:\Users\me\Documents\my-project'; ${env:PYTHONIOENCODING}='UTF-8'; ${env:PYTHONUNBUFFERED}='1'; & 'C:\Users\me\Anaconda3\python.exe' 'c:\Users\me\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\ptvsd_launcher.py' '--default' '--nodebug' '--client' '--host' 'localhost' '--port' '51699' 'c:\Users\me\Documents\my-project\hello.py'
hello, world
distance 5.0
PS C:\Users\me\Documents\my-project> C:/Users/me/Anaconda3/Scripts/activate
PS C:\Users\me\Documents\my-project> conda activate base
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 activate base
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (conda:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\me\Documents\my-project>
They are not useless, you just happened to be running a file that happens to not need a specific conda environment activated. It's a general problem with conda that we're trying to solve. The smoothest experience would be to use virtual environments if that will work for you.

Categories

Resources