Run python module commands on Windows - python

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.

Related

How do you open Jupyter Notebook without Anaconda and from any directory?

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

Install python using chocolatey on shared windows gitlab runner (powershell)

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

How to run files in the working directory through Git Bash and Python

I'm having some issues running Python 3, which I installed with Anaconda, through Git Bash. I'm able to access the interactive environment by entering python but whenever I enter:
python webscraper.py
I get this:
C:/Users/[My username]/anaconda3/python.exe: can't open file 'webscraper.py': [Errno 2]
No such file or directory
The Python file is in the same directory I'm currently working in when I'm getting these errors. The path to my version of Python through Anaconda also looks like it's correct. I was previously able to test scripts in Bash but had to reinstall it to solve some other issue.
First, check if you are using the right python:
which python # in your git bash session
Then test it with the full absolute pathname of the file, as described here:
python /full/path/to/webscrapper.py

My command prompt doesn't seem to recognize "pip". What can I do to get it to work?

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...

Installing Django Error

I am trying to install Django by using a tutorial.(tutorial.)
I download the latest release (1.6.2) and untar(unzip) it.
Then I open the file that contains Django on my Desktop and copy the Directory.
I open the command prompt.
From C:\Users\Name\Desktop> I type cd and I paste the Directory.
This opens the Django directory which is C:\Users\Name\Desktop\Django-1.6.2
Inside this file there is a setup.py file.
According to the tutorial if I type python setup.py install it will install Django for me! And this actually happens in the tutorial video but not in my case!!!
When I type it gives me the following:
'python' is not recognized as an internal or external command, operable program or batch file.
If I go into the Django file and Double-click the setup.py file I momentarily see in the window (before it closes) error: no commands supplied
What must I do? I am trying to install Django for 2 days now and it is getting really frustrating.
SOLVED
Must set Path Variable from Environmental Variables FIRST!
For a quick solution, look at the answer + this post and choose melhosseiny's answer.
Use the command C:\Python27\python setup.py install
Additionally, if you don't want to add C:\Python27\ to all of your python commands, you need to add it to your Windows Path. This can be done by going to your environment variables and add C:\Python27 (notice the lack of a trailing slash) to the PATH variable. Make sure you are adding to, not replacing, the values there are present.

Categories