Running Anaconda Command From Visual Studio Code's power shell - python

I know it's possible to run anaconda commands from anaconda prompt but it is more convenient to run it from the powershell of visual studio code like basic python where we can install the package by simply writing 'pip' command. Is there any similar way for anaconda in vscode?

If you didn't install conda to your PATH then this is by design of conda itself unfortunately.

You can just activate your conda inside a VS Code terminal:
/path/to/Anaconda3/Scripts/activate
Then you can use the same commands you can with anaconda prompt, like
conda activate env
for example

Related

discord py in Visual Studio Code not detecting extension

I installed discord.py with the voice and without in the visual studio code terminal because in my cmd it doesn't detect pip like a command (I'm on windows). I've tried too in the python terminal but it doesnt detetect pip like a command.
Please help.
Pip is installed, it's just not installed as a command, and that's on purpose. What you want to do is create a virtual environment and then install into there by activating the environment and then using python -m pip.

Visual Studio 2019 install Python3.7 Package, geting TLS/SSL problem

I was trying to install Python3.7 package inside visual studio however I keep getting
"pip is configured with locations that require TLS/SSL, however the SSL module in Python is not available." issues, no matter what package.
The OS is windows I also tried to use CMD to pip, it seems package can be successfully installed, but it does not reflect in Visual Studio. Tried reinstall Python component in Visual Studio but with no luck.
The visual studio does have both 3.6 and 3.7 and I have Anaconda. Install package works with 3.6 in VS but not for 3.7. I really don't know where else to look for problem, could be some path configuration problem, environment variable problem?
I experienced similar symptoms and was able to find a suitable workaround.
Background:
Fresh install of Visual Studio 2019 in May 2019, no previous install of anaconda, etc. I could add pypi packages in 3.6 conda environments, but not 3.7. Attempts to install from both VS2019 and powershell would result in the ssl module error you describe.
Workaround: I was able to work around this by running pip install from the conda command prompt.
To do this, I navigated to the conda folder, which for me was at:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\Microsoft\Python\Miniconda\Miniconda3-x64\Scripts.
I could run conda.exe but it errors out saying the environment isn't set up. If you modify your path to include the above directory plus several other parent and subs (miniconda3-x64 root, library, library/bin; condabin; maybe others) the error message will actually give you helpful instructions to run conda init cmd.exe or something similar to prepare your environment. You can run this for powershell as well. I ran this as admin. Close your shell and reopen, and then you can run conda activate <environment>. Once in the conda shell, I could run pip install <package> and it all worked fine, and was reflected in VS2019 view immediately.
TL;DR: Navigate to the folder where conda.exe lives; run conda init cmd.exe as admin; reopen cmd.exe; run conda activate <environment name>; run pip install <package name>; run conda deactivate; return to VS2019, verify, rejoice.

How can I access the vim installed with the anaconda prompt?

I've started the Anaconda python distribution. This comes with something called
'Anaconda prompt' that has conda and git available at the Windows command line.
When I make a commit from this command line, Vim comes up as the editor.
When I type 'vim' or 'vi' at this prompt I get the message:
'vim' is not recognized as an internal or external command, operable
program or batch file.
How can I access vim from the Anaconda prompt?
I was facing the same issue while using vim or vi commands because the package was not installed on my machine. To use the vim command of anaconda prompt with windows os, then use this given command ' conda install -c conda-forge vim '. This command will install the required dependencies and then just simply use the vim command example - vim file_name.
Reference
I am on a mac, but have been using the anaconda prompt on my Windows work machine. You need to add the path of the vim tool to the Windows path environmental variable. I set mine up to use notepad++ when I did a recent install. You can probably find vim in the %APPDATA% directory where anaconda is located if you installed it under the user and not the system. If you search for vim there, you might fine it. If it isn't there it might have gotten installed with another tool.
Install PyVim instead as below and open your textual files in your Anaconda Prompt:
pip install pyvim

Windows 10 conda is not recognized as an internal or external command

Tried to
conda install -c conda-forge requests-futures=0.9.7
but failed with
conda is not recognized as an internal or external command,
C:\Users\user_name\Anaconda3\Scripts has been set for Path in environment variables under both user and System variables.
I installed Python 3.5 as well and it is on Path, I am using Win10 X64.
How to fix the issue?
When you install anaconda on windows now, it doesn't automatically add Python or Conda to your path.
If you don’t know where your conda and/or python is, you type the following commands into your anaconda prompt
Next, you can add Python and Conda to your path by using the setx command in your command prompt.
Next close that command prompt and open a new one. Congrats you can now use conda and python
Source: https://medium.com/#GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444
There is a similar question asked here before, check this may be it will help you.
To make sure that conda package is installed correctly, check if conda package files , i.e conda conda-env conda-env-script conda-script conda-server conda-server-script etc are present in Anaconda3\Scripts folder.
I had a similar problem when using cmd.
From your Command prompt 'C:\Users\zkdur\anaconda3\Scripts
Now try
conda init --help
conda init --verbose after that restart your command prompt and conda will be working.
After installing Anaconda on windows 10, you can use Anaconda prompt from start menu to activate a conda enabled terminal window.
Just Check Both the options while installing Anaconda.
(https://i.stack.imgur.com/WogNs.jpg)

Switch between spyder for python 2 and 3

From what I have learnt in the documentation it states that you can easily switch between 2 python environments by just creating a new variable using command prompt
"conda create -n python34 python=3.4 anaconda" if i already have python 2.7 installed.
An environment named python 34 is created and we can activate it using "activate python 34" But all this happens like executing the above commands happens in my windows command prompt. I want to switch between python versions in spyder IDE, How to do this?
Spyder is launched from the environment that you're using.
So if you want to use python 3 in Spyder then you activate python34 (or whatever you named the environment with Python 3) then run spyder.
If you want to use python 2 in Spyder then you deactivate the python3 environment (or activate an environment in which you installed Python 2) then run spyder.
I do not believe that you can change environments once Spyder is launched.
N.B. you may need to install Spyder in each environment, depending on your set up, by first activating the environment then using conda install spyder.
Just go to preferences in spyder & then go to Python interpreter-> Use the following python interpreter: here, from browse files option, give path for your python2.exe file & then apply. Now your python2 doesn't have spyder-kernels module required to open console in spyder so install it by writing command in cmd python2 -m pip install spyder-kernels. Here python2 -m is used coz I have two versions of python installed
Just go to the directory where you have installed Spyder(use cd in command prompt), for me, it looks like "C:\Users\Rohan\Anaconda2" and type spyder in cmd. it will run your Spyder IDE.

Categories

Resources