Asish M.
Asish M.

Reputation: 2647

Python virtualenv with Anaconda and python.org python 3.5

I have both anaconda Python 3.5 and Python 3.5 from python.org (on windows)

python -V
Python 3.5.1 :: Anaconda 4.0.0 (64-bit)

python3 -V
Python 3.5.1

py -V
Python 2.7.12

I want to create a virtualenv with only python 3.5.1 and not the anaconda version.

When I run

python3 c:\Python35\Tools\scripts\pyvenv.py venv

python -V still shows Python 3.5.1 :: Anaconda 4.0.0 (64-bit) after activating the environment

Is there anyway to get it to use the native 3.5 version?

Upvotes: 0

Views: 694

Answers (1)

user1992836
user1992836

Reputation:

You can use command line option -p during venv creation to force a particular interpreter to be used with it.

python3 c:\Python35\Tools\scripts\pyvenv.py -p python3 venv

Edited:

My bad, wrong virtual environment. As I can see you use venv from standard library and it's impossible to choose particular interpreter during virtual environment creation. On the other hand python3 -m venv venv command should use python3 interpreter for virtual environment which is one without anaconda in your case.

Edited 2:

I've just checked on windows:

C:\Users\usr>where python
C:\Python35\python.exe
C:\Users\usr\Anaconda3\python.exe

C:\Users\usr>C:\Users\usr\Anaconda3\python.exe --version
Python 3.5.2 :: Anaconda 4.1.1 (32-bit)

C:\Users\usr>C:\Users\usr\Anaconda3\python.exe -m venv myanacondavenv

C:\Users\usr>myanacondavenv\Scripts\activate.bat
(myanacondavenv) C:\Users\usr>python --version
Python 3.5.2 :: Anaconda 4.1.1 (32-bit)

(myanacondavenv) C:\Users\usr>deactivate
C:\Users\usr>C:\Python35\python.exe -m venv myvanilaenv

C:\Users\usr>myvanilaenv\Scripts\activate.bat
(myvanilaenv) C:\Users\usr>python --version
Python 3.5.1

(myvanilaenv) C:\Users\usr>deactivate
C:\Users\usr>

Reference

Upvotes: 1

Related Questions