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.
Related
I am trying to run a simple command in a .py file on Visual Studio Code, namely:
import os
I get the following return in the terminal:
& : The term 'C:/Users/Tim-S/anaconda3/envs/plotlyenv/python.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:3
+ & C:/Users/Tim-S/anaconda3/envs/plotlyenv/python.exe "c:/Users/Tim-S/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:/Users/Tim-S/...yenv/python.exe:String)
[], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Can anyone explain me how I can solve this?
Start by installing Python from python.org or choco. Then, in your terminal (cmd, powershell, windows terminal, etc.), run python. Only then, should you attempt to run anything in VS Code.
You may already be having success up to that point, but it isn't clear from your question. I can see you have some environment (anaconda) installed. There are several VS Code plugins for Python. This answer may help you further with that part.
Here is the Windows port of pyenv, which is an excellent version management tool, which may also be of use.
Are you trying to create a virtual environment: by the looks of the path in the error - 'C:/Users/Tim-S/anaconda3/envs/plotlyenv/python.exe'
seems like you are trying to do so. IF that's the case:
Possible it did not get installed properly and hence cannot find the python file
you have to reinstall it and activate the environment
But that will solve the problem partially
After activating virtual environment, you have to install the library
that you are going to use
What I can see from your problem statement and file path you will need to install os and plotly
pip install os
pip install plotly - if required
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
I know this has been asked before and I reviewed the previous posts, but none of those solved my issue.
I'm new to programming so I may get the terminology mixed up but I will try to explain in as much detail as I can.
I am running Python 3.8 on Visual Studio Code. I installed pipenv successfully:
python -m pip install pipenv
Then I try to actually use it and get this error:
pipenv shell --python 3.8
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 --python 3.8
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (pipenv:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
During installation I got this warning:
WARNING: The script f2py.exe is installed in 'C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
However, I don't actually know how to do this or even if I should, because I get this warning with every package I install but it works fine anyway.
I am following this tutorial:
Video Tutorial
and the guy specifically says to run the pipenv commands in the directory where our project is, which I am doing and I get this error. Nevertheless I tried to cd to the directory where the pipenv installed and same error.
I am on Win 10 btw. What am I doing wrong?
You may need to add pipenv to you path variable. Check out the note section in the docs. It actually describes how to get the right location to add on Windows:
On Windows you can find the user base binary directory by running
python -m site --user-site and replacing site-packages with Scripts.
For example, this could return
C:\Users\Username\AppData\Roaming\Python36\site-packages so you would
need to set your PATH to include
C:\Users\Username\AppData\Roaming\Python36\Scripts. You can set your
user PATH permanently in the Control Panel. You may need to log out
for the PATH changes to take effect.
That should get it recognized by your terminal.
The last sentence of that reminds me (it's been a while since I used Windows) -- have you tried to restart or logout? I'm not sure if that's necessary to be honest but I know sometimes it is.
Long story short (and only since you mentioned that you are new to programming) -- the "path" lists all of the locations that are accessible to execute from. You can add to it if you want to be able to execute new programs, like pipenv.
This is what solved the issue for me (Windows 10):
I added the correct Scripts folder of the Python version I am actually running. In my case this was C:\python\Scripts. I added that in Control Panel - search "environment" - Edit environment variables (both for my account and system-wide - did it on both places just to be sure, maybe redundant) - Path - Edit - added the path and now the issue is solved. Thank you!!! –
I have an existing vanilla Python installed on my Windows 10 computer and I do not want to reinstall Anaconda.
When trying to run code from ipynb file in vscode, I get the following error:
Error: Jupyter cannot be started. Error attempting to locate jupyter:
at A.startServer (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:1:786120)
at async A.ensureServerAndNotebookImpl (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:1:785575)
at async A.ensureServerAndNotebook (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:1:785376)
at async A.submitCode (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:1:782328)
at async A.reexecuteCell (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:75:879318)
Also with the following error from VSCode:
Below are some of the things I have tried:
Check if the VSCode Extension in Correctly Installed
"Jupyter" extensions is deprecated. I had the "Python" plugin from Microsoft installed which contained Jupiter Notebook support.
Jupyter Installed Correctly
I tried reinstalling jupyter:
> python -m pip install --upgrade pip
> pip install jupyter
> pip install notebook
Tried to Run Jupyter on Terminal/Command Line
> jupyter notebook //didn't work
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
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (jupyter:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This gave an error not able to find jupyter executable.
According to this post I tried the following and it worked:
> python -m notebook
Check if pointing to the right interpreter
As per this post I tried:
Press Command+Shift+P to open a new command pallete
Type >Python: Select Intepreter to start jupyter notebook server
But I only had one version of Python installed on my computer, and doing this didn't make a difference.
Check the Path
There was this comment about PYTHONPATH in this post but since the python directory is correctly referenced and python works from the command line, I did not investigate it further.
One thing to note is pip installs to my "C:/Users/[username]/appdata/Roaming/Python-38/" folder while my Python is installed in "C:\Program Files\Python38-32\".
If you are having similar issues, please try the above steps mentioned in the question.
After reading this article I realised that I had to map the scripts installed with pip as well, even if it is in my roaming directory. https://discuss.python.org/t/windows-appdata-roaming-vs-local/2682. A confusion that costed me so many hours.
Here are the steps to add the variable:
Go to environmental variables (if you don't know how, here is some instructions: https://www.techjunkie.com/environment-variables-windows-10/)
In the "User variables for [username]" section, Edit "PATH" variable. (it can't be System variables section because only you will have access to your own roaming folder)
Add "C:\Users[username]\AppData\Roaming\Python\Python38\Scripts" (or where the pip installs the scripts to to the PATH variable.
Finally restart VSCode for the new environmental variable to be updated for VSCode.
Now run the scripts in the ipynb file and it should work. It may also complain that it needs other modules, in which case you can use 'pip' to install it.
NB: if you are not constrained by having an existing python version on your computer and not wanting to install more, you can also use the Python Anaconda Distribution. https://www.anaconda.com/distribution/
NB: if you want jupyter note to work for all users using your computer, you need to configure pip to download installs to a directory that is not in your "C:\Users[username]" folder, and add a System variable to it.
For me, another solution helped. I'm not quite sure, what was the issue though, but somehow the state stored for the exact workspace made Python extension crash.
VSCode stores the states for all the workspaces, in its global config folder under /Code/User/workspaceStorage/. See the path to the settings.json in this help paragraph for your OS and then just replace the end of the path. For Windows, for example, the settings path is %APPDATA%\Code\User\settings.json, so the state storage is
%APPDATA%/Code/User/workspaceStorage/
In this directory, there are many subdirectories with some hex names, which are hard to relate to the workspaces. To find out the id of the workspace
Open it in VSCode
Help → Toggle Developer Tools
In Console tab there execute the following to get the workspace id:
vscode.context.configuration()["workspace"]["id"]
Then you can delete the workspaceStorage subfolder by the id of the workspaces.
Another approach is by using the workspaceStorage folder contents themselves. Each of this folder contains a workspace.json which usually includes the path to the workspace. So I wrote a little python script to help me browse them. At the end of the script, there is a draft on removing all the workspaces for the remote containers. Feel free to modify it according to your needs.
from glob import glob
import os, json, sys
from shutil import rmtree
if sys.platform.startswith("win32"): path = os.environ["APPDATA"] + '/Code/User/workspaceStorage/' # Windows
elif sys.platform.startswith("darwin"): path = os.environ["HOME"] + '/Library/Application Support/Code/User/workspaceStorage/' # Mac OS
elif sys.platform.startswith("linux"): path = os.environ["HOME"] + '/.config/Code/User/workspaceStorage/' # Linux
for f in glob(path + "*/*.json"):
with open(f) as fr:
ws = json.load(fr)
d = ""
if "folder" in ws.keys():
d = ws["folder"]
elif "workspace" in ws.keys():
d = ws["workspace"]
elif "configuration" in ws.keys():
d = ws["configuration"]["fsPath"]
ws_path = os.path.dirname(f)
print(d, ws_path)
if d.startswith("vscode-remote://attached-container") or d.startswith("vscode-remote://dev-container"):
print("Inside a container")
# rmtree(ws_path)
I just installed python on VS Code and I can't run any python code using python command.
python command:
Running the code seems to run python command by default and it does not recognize it.
When I right click and choose Run Code it complains:
'python' is not recognized as an internal or external command, operable program or batch file
Same goes for manually running python main.py.
When I open an elevated PowerShell and run python, it complains:
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
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
py command:
It doesn't try to use py command but it recognizes it. And when I manually call py main.py, it works.
When I manually do >py main.py it writes my Goodbye, World!
Question:
How can I make it compile/run in VS Code simply by using the CodeRunner's right-click feature (Run Code)?
I already have both Python folder and its Scripts folder in PATH.
I'm using VS Code 1.27.2 and I have installed python 3.7.0 on my machine and have checked its installer checkbox for adding the environment variables automatically. (PATH is ok)
I also installed : ms-python.python and tht13.python and formulahendry.code-runner extensions on the VS Code.
This is my main.py code:
print("Goodbye, World!")
It turned out that I just had to restart my computer after I installed ms-python.python and tht13.python and formulahendry.code-runner extensions on the VS Code and added python's Scripts folder in PATH.
Now both py and python commands work from anywhere like cmd or Run Code in the right click menu.
Restarting your PC after installing the Python Extension and changing the PATH to include Python and it's scripts folder will help. Worked for me
The Windows installer for Python does not put python on your path by default (there's a checkbox during installation to add it). Make sure that you selected an interpreter that's installed by running Select Interpreter and choosing the interpreter you want (the extension will find them through the registry).
I also had this problem after a fresh Windows reinstallation, vscode didnt recognize the commands like python or pip freeze in the PS terminal.
After reinstalling python and vscode, I read the tutorial for python for vscode: https://code.visualstudio.com/docs/python/python-tutorial. Creating a new venv worked for me py -3 -m venv .venv, then navigate to the venv: .venv\scripts\activate. In the new venv all the python commands worked as normal.
If you have already set the path variable, test the same command in a command prompt and see if it works. If it does, just update PowerShell's path settings by running the following from your vs code PowerShell terminal:
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path","User")`
This trick can save you a lot of restarts.
you need to first confirm if python is installed, for that just run python/python3 on terminal/cmd.
If it runs there and it isn't running in VS Code then restart your system in order to get changes reflected.
And if it doesn't run in terminal/cmd as well then first check if python's directories are placed in environment variables.
Add Python path (ex C:\Users\johndoe\AppData\Local\Programs\Python\Python39) to the %PATH% env variable
I added PATH and did everything. but it didn't work on Vscode Powershell.
but python was working in windows CMD. So I just reinstalled Vscode.