Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running python from a conda environment on windows

I have decided to have both python 2 and 3 installed on my Windows PC. Python 3 was included with Anaconda, and works flawlessly after the installation of Anaconda.

After having created successfully a python 2 environment:

conda create --name py27 python=2.7

I noticed that no python.py file has been created in C:\Users\Hélain\IT\Anaconda3\envs\py27.

Typing python in my terminal launches my python 3 python and py27 is not considered a command. Activating or deactivating the environment does no change this behavior.

Result of typing python:

C:\Users\Hélain>activate py27
Deactivating environment "C:\Users\Hélain\IT\Anaconda3"...
Activating environment "C:\Users\Hélain\IT\Anaconda3\envs\py27"...

[py27] C:\Users\Hélain>python
Python 3.4.1 |Anaconda 2.1.0 (64-bit)| (default, Sep 24 2014, 18:32:42) [MSC v.1
600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

How do I run python with my environment's version and packages?

like image 250
Heschoon Avatar asked Dec 26 '15 11:12

Heschoon


People also ask

How do I run a Python file in a conda environment?

Windows. From the Start Menu open the Anaconda Prompt. If you want the location of a Python interpreter for a conda environment other than the root conda environment, run activate environment-name . Run where python .

How do I run a Python script in virtual environment Windows?

In "Program/script" textbox you set the path to Python executable (in my case is inside the virtualenv folder). "Add arguments" => Just the name of your Python script (name. ppy). "Start in" => The full path of your Python script (without the name.py).

Can I run Python from Anaconda prompt?

Click Start�All Programs�Anaconda (64-bit)�Anaconda Command Prompt. � A command prompt window will open. Type idle to run the Python interpreter. A new window titled Python Shell will open and you will see the Python >>> command prompt.

Does conda work on Windows?

Conda is an open-source package and environment management system that runs on Windows, macOS, and Linux.


1 Answers

In your terminal type:

activate py27

The prompt should change to (py27).

Now you can install packages in this environment. For example:

conda install jupyter matplotlib

Launch Python from this terminal with:

python 
like image 99
Mike Müller Avatar answered Oct 10 '22 02:10

Mike Müller