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

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.

Related

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.

Running scripts in Spyder using windows Command Prompt or PowerShell

I would like to know if there is a way to run python scripts in spyder-ide using windows cmd or PowerShell instead of IPython console.
Ipython sometimes works differently than if the script is run in cmd specially for plotting packages like matplotlib, etc.
I am using Spyder latest version.
Regards
In Spyder, you can click Run > Configuration per file, which will give you plenty of options in where your Spyder-IDE-Script is launched.
I think the option you are looking for is "Execute in External System Terminal" in the options found under the menu item of [Tools] / [Preferences] / [Run]

How to open Python Terminal?

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"])

VS Code: python.exe works in terminal only when opened from Anaconda Navigator

When launching Visual Studio Code from the Anaconda Navigator page, the python command works correctly in the integrated terminal (Powershell or Bash).
However, when Visual Studio Code is launched normally (from start menu), python.exe is not found in the terminal (not in path).
Is there a way to always apply Anaconda's config to VS Code, to avoid having to launch it from the Anaconda Navigator page?
When you installed Anaconda you probably had it leave the copy of Python in your base environment off of PATH. That means when you open your terminal it won't be found normally (this isn't specific to VS Code). One way to deal with this is to create conda environments for your project as those will get activated in the terminal when you use the Python: Create Terminal command. That will then make python available as a command from your terminal.

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