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 #ᴓᴓᴓ!)
Related
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\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).
I am facing an issue with the Windows 10 Powershell. Whenever I open it I get an error:
& : The term 'C:\Users\hp\anaconda3\Scripts\conda.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 C:\Users\hp\Documents\WindowsPowerShell\profile.ps1:4 char:4
+ (& "C:\Users\hp\anaconda3\Scripts\conda.exe" "shell.powershell" "hook ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\hp\anaconda3\Scripts\conda.exe:String) [], CommandNotFoundExce
ption
+ FullyQualifiedErrorId : CommandNotFoundException
Previously I had installed anaconda and vs code to work in python but later I uninstalled anaconda and downloaded python3 from https://www.python.org/downloads/.
I have added the environment variables for Python in Path but still I get this error in the Powershell.
How to fix this?
Uninstall any other python interpreter installation and restart to refresh env variables
Download Anaconda Installer from here
You should add it to PATH if you want to use it outside of Anaconda Navigator and I recommend you install it systemwide with admin privilege
This should add conda executable to PATH allowing it to be called systemwide
My IT department does not give me the ability to use pip or easy install to install Python library packages from PyPi.
At some point I figured out that I could download the Python packages, extract the contents with 7-Zip until I exposed the setup.py file. Then by opening the command line in this same location I could type
set path=%path%;C:\Python27\ArcGIS10.7\
and
python setup.py install
to install the libraries into my Python directory. This trick worked perfectly on Windows 7.
I have since been 'upgraded' to Windows 10. When I try my installation trick the Windows PowerShell returns this
PS C:\TEMP\simplekml-1.3.1> set path=%path%;C:\Python27\ArcGIS10.7\
C:\Python27\ArcGIS10.7\ : The term 'C:\Python27\ArcGIS10.7\' 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:17
+ set path=%path%;C:\Python27\ArcGIS10.7\
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Python27\ArcGIS10.7\:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
How do I install these Python Packages in Windows 10?
You are able to edit environment variables like so:
$env:path = $env:path + ";C:\Python27\ArcGIS10.7\"
Please check beforehand if there is a semicolon at the end of $env:path or not.
You may not get access to set up the environmental path or any other other files to set up in C: drive, better you download in desktop and unzip the Python files and go to script and go to command prompt with the path and try to install using PIP because you have full control on desktop no need to ask permissions.
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.