I'm trying to set up an automatic python build on windows using shared windows runners on gitlab. I am able to install python using chocolatey, but when I try to use python, I get the error:
python -m pip install numpy
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.
I have tried using the refreshenv command as recommended here, but it gives me the result
Refreshing environment variables from registry for cmd.exe. This sugests that the powershell profile is not loaded. Ordinarily I would restart the powershell window to reload the profile but I cannot do that in the CI pipeline.
How can I use python in the current powershell window
Related
I need help opening Python using the command line from other folders. Currently, I can only open Jupyter Notebook via the command line in the directory that Python was installed in. The following commands worked:
python -m jupyter notebook
or
python -m notebook
Excluding python -m or -m results in an error.
When trying to access python from any other folders using the same commands, I get the following error:
'python' is not recognized as an internal or external command,
operable program or batch file.
A similar error is thrown when I use jupyter notebook or notebook.
I have downloaded Python and have used it using IDLE. I also installed Jupyter Notebook using pip; I did this by accessing Windows Powershell in the folder where Python is located.
Would appreciate it also if someone could explain what was happening and what I could do in the future to avoid this. Thank you for the help!
Python is not recognised outside its own folder (as you mention). To 'expose' the Python command to the console, you can add it to your Windows environment variables, as per the Python documentation.
To permanently modify the default environment variables, click Start and search for ‘edit environment variables’, or open System properties, Advanced system settings and click the Environment Variables button. In this dialog, you can add or modify User and System variables. To change System variables, you need non-restricted access to your machine (i.e. Administrator rights).
Concretely, in the environment variables of your system, edit the 'PATH' variable and add the folder with your Python executable to the path. After restarting your command prompt you should now be able to execute python commands.
While installing the Python, you can choose to add Python to PATH, if you check this while installing, you will have environment PATH variable in the machine.
Then you can just install notebook as you install any other packages/libraries in python.
pip install notebook
Once you do that, you should be able to start notebook from any folder/directory in your machine.
the command is pretty simple.
jupyter notebook
I installed Sphinx using pip install sphinx command in Windows Terminal and I want to run sphinx-quickstart to make documentation in my docs directory but it doesn't work.
I get this error instead:
sphinx-quickstart : The term 'sphinx-quickstart' 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.
If I try to run it via GitBash or using py or python at the beginning that says:
\path_to_python\python.exe: can't open file '\My_working_directory\docs\sphinx-quickstart': [Errno 2] No such file or directory
How can I solve this problem?
The easiest way to do it is to create simple virtual environment and you will able to install packages you want and run it.
Just create folder and run command to create virtual environment then just activate it using .bat file.
Read the docs but it can differ in future versions of Python.
I'm trying to use Tweepy and am trying to install it but typing in
"pip install tweepy" results in:
'pip' is not recognized as an internal or external command, operable
program or batch file."
This is a windows 10 pc. I've been trying this on the command prompt. I've tried changing the path in the windows settings.
'
C:\Users\Orlando>pip install tweepy 'pip' is not recognized as an
internal or external command, operable program or batch file.
I expect it to begin installing Tweepy but instead I get this error message.
Go to environment variables
and add to PATH the following paths
...\PythonXX\
and
...\PythonXX\Scripts\
where ... is your Python installation directory
The reason that pip is not working on your pc is that ENVIRONMENT PATH is not set to your python script directory you can add that simply like:
Press WIN+R and type in SystemPropertiesAdvanced click on Environment Variables button
then search for path in System variables and add a new entry as described by #bleand,
i.e., YOUR PYTHON INSTALLATION DIRECTORY\Scripts
you can find your PYTHON INSTALLATION DIRECTORY by This stackO answer
I this did't works then try this SO answer for installing pip in your system
Try reading Command line and environment for getting the reason why py -m pip install PACKAGENAME works..
Thanks...
this is my first time on posting a thread on stackoverflow, but I have used this many times in the past. I am having a problem when compiling my python files. I have looked many times on here and on other sites on how to do this and I keep getting the same answers. For some reason, on my computer, I cannot run/install pip. Whenever I try to install pip by using the python command, it is not recognized. I saw a thread on here about using 'py' instead of 'python', this is accepted as a command but when I try to install pip it just errors. I have installed python several times and have also repaired it several times, but nothing seems to work.
Any help would be greatly appreciated!
Welcome to stackoverflow!
this is an image i took from a website if you would like to use PIP
the website: https://packaging.python.org/tutorials/installing-packages/#ensure-you-can-run-pip-from-the-command-line
I took a look at the directory that you specified in your comment. Pip is not an executable file there, but rather is python source code. What I found that worked and allowed me to run Pip successfully was to import Pip as a module within the system Python environment. Then run Python specifying Pip as a loaded module using the -m flag to call pip as an executable with its own arguments (e.g. C:\Users>python -m pip --version). The steps to set this up are included below:
Step 1: Verify that Python is installed and is added to your PATH variable
From cmd, run the command: C:\Users> where python. You should be returned a file path to the executable for Python.
If instead you receive an error message that says the following: "INFO: Could not find files for the given pattern(s)." that means that Python is not added to your $PATH variable (See below for details on how to configure your PATH variable.
Step 2: Add Pip source code as a module within Python
Run python from the cmd: C:\Users> python
Run the command import pip within the python shell:
Run the command exit() to return to the cmd from the Python shell.
Step 3: Validate that pip can be used as a module within Python
Run the following command to check Pip's version as a validation that Pip and Python are configured correctly: C:\Users> python -m pip --version
Validate that you are returned a version number
Configuring PATH environment variable (Windows 10)
From the start menu search box, type "edit the system environment variables".
Open the application that is returned (should pop open the control panel).
Click the button entitled 'Environment Variables'
If you have a variable defined as 'PATH' already, click the edit button, then click 'new' in the following dialog box. Specify the path to your Python executable ( C:\Users\jakes\AppData\Local\Programs\Python\Python37-32\Lib\site-packages). Click 'Ok' and then 'Apply.'
If you don't already have a 'PATH' variable defined, click 'new' and define a name of 'PATH' and add in the file path to the Python executable as the variable's value.
Close any active Command Prompts! After making changes to your PATH variable,you will need to close any active sessions in order to allow the update PATH variable to be propagated within the session.
Open a new Command Prompt window and run the command: C:\Users> where python to verify that the your changes were made correctly, and that they have fully propagated within the system.
I want to set up Python SimpleHTTPServer on windows XP. I have Python installed on my computer. I am executing the following command:
python -m SimpleHTTPServer 8888
But I am getting the error:
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.
Looks like Python is not in your PATH enviroment variable. To fix this try this answer:
https://stackoverflow.com/a/6318188/6400392
Hold Win and press Pause.
Click Advanced System Settings.
Click Environment Variables.
Append ;C:\python27 to the Path variable.
Restart Command Prompt.