How to open Python Terminal? - python

I am learning Python from the Internet. I have downloaded Python 3.6 and Spyder from Anaconda. Using Windows 10 device. I need to install speech recognition library, using code:
sudo pip SpeechRecognition
and for that I am not able to use Spyder.It shows a syntax error. I need to open the python terminal.

Go in the Start Menu, and look for the "Anaconda3" item, and use the Anaconda Prompt item there to launch a shell session with the environment set up. Then you can type
python
at the prompt, and it will start the default Python you've installed for Anaconda

Press WIN + R, then type cmd and press ENTER.
Type in the following command and press ENTER and the installation will began.
pip install SpeechRecognition
If you have a virtual environment set up, however, execute source activate {environemt_name} before running the above command.
Type python and press ENTER to open Python Terminal.

As others have said, you should install in the cmd prompt.
There is an option to install in your IDE (Spyder)
You can run the following:
import pip
pip.main(["install", "SpeechRecognition"])

Related

(Terminal: Create New Integrated Terminal) not found in vs code

I need to install some package of python (numpy,pandas ..)in vs code.
for this action I need to Terminal: Create New Integrated Terminal but I don't found this command on command bar
If you need to install these python packages you don't need to open vscode's terminal you can just open the command console or a powershell and type :
pip install numpy
for example
And if you want the vscode terminal:
Normally it should be here you need to click Terminal > New Terminal
If you can not find this:
Could you try to create it with the shortcut of Ctrl+Shift+` Or click the plus button in the terminal?
And you can switch to the anaconda environment to reuse the packages, you can refer to here for more details.

Python is not installing on Windows 10

I tried to install Python to Windows 10, with the PATH installation included. However, when I click to enter in the Python application, it just appears the setup. I need to access the Python terminal.
Here is the setup
Make sure you are not accidentally opening the Python installation executable. Check again that the Python path is installed properly and try running the command "py" or "python" in the Command Prompt to see if it starts. If it doesn't start and Python is installed on your computer, manually add Python's install location to your PATH.

Visual Code on Windows can't find module after installing it with PIP. Using wrong Python in Terminal window?

I am using Visual Code 1.47.0 on Windows 8.1 with the latest version of the Python extension installed too. I just installed a module using pip. I then created a new Python file to test it. The IDE highlights the import statement as an error and the drop-down info box says "Unable to import 'extpylib'. If I try to run/debug the test file, I get a traceback error saying:
C:\Users\User\AppData\Roaming\Python\Python38\Scripts
Exception has occurred: ModuleNotFoundError
No module named 'extpylib'
File "C:\Users\user\Documents\PythonProjects\test-extpylib.py", line 2, in <module>
import extpylib
If I run the pip install command again, even with the "--upgrade" command line argument, it says everything is installed and that I'm using the latest build. I am wondering if this is happening because the VSCODE Terminal window is still using Python 2.7, and not the version I have selected in the status bar, which is Python 3.8.3 64-bit? I am not using the Code Runner extension.
I assumeg that this mismatch of versions between the IDE and the VSCODE Terminal window is causing my issue? If so, how can I get the VSCODE Terminal window to use the same version as that which is selected in the IDE? If not, what is the real problem and how can I fix it?
You may have many python paths and VS code is using the wrong one. Choose the right interpreter path just clicking here:
I solved this by closing and re-opening the vs-code after installing new package.
It seems like an environment issue. In my own Visual Studio code integrated terminal, when I type which python and which pip, I get the correct path to both python and pip executables. So this:
I am wondering if this is happening because the VSCODE Terminal window is still using Python 2.7, and not the version I have selected in the status bar, which is Python 3.8.3 64-bit?
Definitely seems to be the issue.
If your VSCODE terminal still uses Python 2.7, you could follow the tips presented here:
However, launching VS Code from a shell in which a certain Python environment is activated does not automatically activate that environment in the default Integrated Terminal. Use the Terminal: Create New Integrated Terminal command after VS Code is running.
and
Note: conda environments cannot be automatically activated in the integrated terminal if PowerShell is set as the integrated shell. See Integrated terminal - Configuration for how to change the shell.
and
Changing interpreters with the Python: Select Interpreter command doesn't affect terminal panels that are already open.
Of course, the package you installed in an environment is independent of other environments.
As you said the VSCode Terminal using Python2.7 while the status bar shows the selected interpreter is Python3.8.3 64-bit. This meaning you are using the global python(3.8.3) to run the python file while you install the package to the Python(2.7) environment.
Solution:
After you selected the python interpreter in the status bar, you need to activate the environment in Terminal through shortcut 'Ctrl+Shift+`'. You can through these commands to check which environment you are using:
In the terminal:
By command "pip --version" to check which pip you are using.
By command "python" -> "import sys; sys.executable" to check which python you are using.
By command "python" -> "import sys; sys.path" to check which 'site-package' the interpreter searching for.
pip command that was used to install the package is based on a different version of python versus what VS Code is using.
Check the python version of your pip command, run pip --version. For example, on my system, this is the output of this command.
$ pip --version
pip 22.0.4 from /Library/Python/3.8/site-packages/pip (python 3.8)
Check the version of code that VS code is using. For VS code 1.61, the python version will be visible at the bottom left corner while a python file is open in the editor. Screen shot of the same is given below. You can also observe from the screen shot that lazy_streams package is not being recognised by VS code.
To solve the error in VS code, update the python version in VScode to be same as that of pip. Updating of the version can be done by simply clicking on the Python version displayed, which will further prompt you to select among all available python versions on your system.

difference between command prompt and anaconda prompt

I installed anaconda into my computer using python. After I install the software, I found there is one program called anaconda prompt.
What is the difference between anaconda prompt and command prompt? If I want to update the package, which one I should use or either one. Like (conda update conda)
Thank you
Anaconda command prompt is just like command prompt, but it makes sure that you are able to use anaconda and conda commands from the prompt, without having to change directories or your path.
When you start Anaconda command prompt, you'll notice that it adds/("prepends") a bunch of locations to your PATH. These locations contain commands and scripts that you can run. So as long as you're in the Anaconda command prompt, you know you can use these commands.
During the installation of Anaconda there is a choice to add these to the PATH by default, and if checked you can also use these commands on the regular command prompt. But the anaconda prompt will always work.
As far as updating conda, if it doesn't work in command prompt, you can do
conda update conda
in Anaconda command prompt.
When you use anaconda command prompt it opened at conda directory (path where all the conda commands run)
like when I was installing pip3 install prettytable on command prompt it successfully installed but not replicate in jupyter notebook.
But when install it using anaconda prompt it replicates intantly
Here is the difference:
PATH-TO behind is the path to Anaconda3
Afer adding the following env to Windows command prompt, it will be the same as Anaconda prompt:
set CONDA_DEFAULT_ENV=base
set CONDA_PREFIX=PATH-TO\Anaconda3
set CONDA_EXE=%CONDA_PREFIX%\Scripts\conda.exe
set CONDA_PROMPT_MODIFIER=(base)
set CONDA_PYTHON_EXE=%CONDA_PREFIX%\python.exe
set CONDA_SHLVL=1
set Path=%CONDA_PREFIX%;%CONDA_PREFIX%\Library\mingw-w64\bin;%CONDA_PREFIX%\Library\usr\bin;%CONDA_PREFIX%\Library\bin;%CONDA_PREFIX%\Scripts;%CONDA_PREFIX%\bin;%CONDA_PREFIX%\condabin;%Path%
I see great answers but maybe it is a little technical for beginners. Anaconda is a (software) distributor, in this case for Python, and its anaconda command prompt is similar to windows command prompt with one important difference: having PATH. PATH, as it can be assumed from its name, is like an address in computer where python packages are installed and their computations will be run.
Having PATH makes a big difference between using python via anaconda prompt or normal command prompt which is considered useful for many research teams and business computers: it will allow you to install, update and uninstall packages inside a separate environment (after creating one!) so that other members of the team wouldn't be disturbed.
When I was working with my own laptop, I never had any problem with running python on jupyter using windows command prompt. But for working with a research team PC, my supervisor made me to create a virtual environment named after me in anaconda prompt just not to disturb any other member. Actually, that was a pain in my neck because I have to activate "my environment" every time before starting python on jupyter. I never understand why someone should not appreciate if I install any more extra packages or updates for them? Not to mention, if in a million years an error pops up due to a package I installed, they can simply uninstall or downgrade it.
So as a normal researcher with medium computations in python, I never liked working with anaconda prompt and windows command prompt was everything I needed, especially on my OWN laptop.
I hope you liked my idea.

Not sure how to fix this Cmd command error?

Im on windows 8 and i have installed the latest python,and im going to use sublime text 3 as my ide to create a website using flask.But firstly i needed to install a virtual enviroment using this command pip install virtualenv,and this is the response i recived by cmd.
C:\Users\osman_000>pip install virtualenv
'pip' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\osman_000>
Please can someone help if you know how to fix this,as im not excatly sure what do from here thanks.
Under Windows, pip is stored in the Python scripts folder, e.g. "C:\Python27\Scripts".
How to run pip?
Open a Command line by pressing [WIN]+R and typing cmd.exe.
Then navigate tho the Scrips folder of your Python installation by typing cd "C:\Python27\Scripts" (Or where else you've installed Python) into the command line.
To run pip now type pip.exe into the command line. This should print a help message.
If so, you can use pip install package_name to install a Python package.
What I recommend:
Navigating to the Scripts folder every time is very annoying, so you can tell Windows where your pip.exe is stored.
Open the control panel, search for "environment variables" and choose edit environment variables.
When a little window is opened, press the button "Environment variables" on the bottom.
Now, double-click the entry "Path", click "New" and enter "C:\Python27\Scripts" (If this is your intallation path, see above). Close all windows with clicking "OK", you're done!
Now opening a commandline and installing through pip should work.
Hope this helps!

Categories