Pydoc won't run on command prompt [duplicate] - python

This question already has answers here:
Pydoc is not working (Windows XP)
(8 answers)
Closed 8 years ago.
I'm working through this "Learn python the Hard Way" book and the book is now saying to run
'pydoc open'
I do this and get the response that pydoc is not an internal or external command etc.
I've trying adding 'C:\Python27\lib\pydoc.py' to PATH and restarting my computer but it still hasn't worked.

Python is probably not in your path. you must add it in your path either by using the GUI or something like this:
set PATH = PATH;/path/to/pydoc/
This is a windows example, but it should not be hard to convert to a *nix version. The export command can be used in that case.

Related

Using Command Prompt to access python [duplicate]

This question already has answers here:
How do I run a Python program in the Command Prompt in Windows 7?
(24 answers)
Closed 1 year ago.
I want to do is create a new python script so that I can start coding in python.
I am new to using windows command prompt. How can I access and create a new python script using the command prompt window? I have tried using cd (location of already made script). I have also just used data\scripts which is where the rest of the python scripts are located.
I have also attached a screenshot of what I attempted.
To access this in the CMD, you just need to type:-
cd data\scripts
Then you will be in your directory.
If you just want shell access, type:-
python
in the interface.

How to keep a terminal opened by Python alive? [duplicate]

This question already has answers here:
How to keep a Python script output window open?
(27 answers)
Closed 3 years ago.
In my Python script, I create a .bat file (many actually), and I run them via
os.startfile(blah)
Everything works like expected, however, those terminals die after finishing. I want to keep them open, so that I can type more commands manually in those opened terminals.
How?
You could try using the cmd command to run the batch file, and then use command line arguments for cmd to modify its behavior. For example:
os.startfile("cmd.exe /k blah.bat")
Documentation of the available command line arguments can be found here:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd

Why is the windows cmd not working for me? [duplicate]

This question already has answers here:
"python" not recognized as a command
(14 answers)
Closed 3 years ago.
While on windows cmd I am coding
C:/Users/Esteban Oquendo/Desktop/python myexample.py
Why I am getting an error message as
'python' is not recognized as an internal or external command,
operable program or batch file.
What I am doing wrong?
You have to make sure that the python.exe folder is in your system path.
Make sure python is installed at the location
C:/Users/Esteban Oquendo/Desktop/
So, make sure python.exe file is present in the directory. If you are not sure where your python is installed. Try this is your windows command line:
which python
You will see the python location if you have python in your system (and if the python path is set correctly). Like this!

How to view the entire history of Python commands in the Mac terminal [duplicate]

This question already has answers here:
Give the Python Terminal a Persistent History
(3 answers)
Closed 5 years ago.
Is there a way to view the entire command history of Python, from the point of the first command 'python' after the installation, in the Mac terminal?
UPDATE: So, it is not possible to retrieve command history from python in the mac terminal. The best solution was proposed by BobStein-VisiBone in how do you see the entire command history in interactive python? where he mentions using iPython. Unfortunately, even that won't help retrieve the history of the commands that were input in the terminal before setting up iPython. In other words, those commands are probably gone for good.
You can try:
history | grep "^[^a-zA-Z]*python *"
This will print out your terminal history of all commands that start with python

Pycharm Command Line Codes [duplicate]

This question already has answers here:
Pycharm and sys.argv arguments
(12 answers)
Closed 5 years ago.
I recently just downloaded PyCharm, and I want to get to know it better, however, codes that I would normally run through the terminal, like an argument parser, I no longer know how to do. Here is an example of what I would put into my command line:
python read_in_data -w wide_data_set -s row_number -o output_path
This would then run the code with my given arguments.
Any basic tips on PyCharm would be helpful, as I am very new to it.
(Top of your screen) Go to Run > Edit Configurations, then enter the command line arguments into the "Script parameters" box. These will then be used when you run the code.
For basic tips/an intro to PyCharm - see the tutorial videos on their website.

Categories