Darcy
Darcy

Reputation: 659

Python path changes depending on conda environment?

I am working in Windows 7 64-bit machine.

I have two modules I am trying to import: vtk and gdal.

Both vtk and gdal are on my PYTHONPATH variable (in System Properties -> Environment Variables).

In command prompt when using Python 3.5, I can import vtk no problem but get an error when importing gdal:

C:\Users\Owner>python
Python 3.5.2 |Anaconda 4.2.0 <64-bit>| <default, Jul 5 2016, 11:41:13> [MSC v.1900 64 bit <AMD64>] on win32
>>> import vtk
>>> import gdal
ImportError: No module named 'gdal'

However, when I switch to the Python 2.7 environment, then the opposite occurs!

C:\Users\Owner>activate py27
<py27> C:\Users\Owner>python
Python 2.7.13 |Continuum Analytics, Inc.| <default, Dec 19 2016, 13:29:36> [MSC v.1500 64 bit <AMD64>] on win32
>>> import gdal
>>> import vtk
ImportError: No module named 'vtk'

Can anyone explain why this is happening?

It seems that, depending on which version of Python I use, the path variable is changing. Or is there something else going on that I am missing?

Any info is appreciated.

Upvotes: 2

Views: 998

Answers (1)

Arya McCarthy
Arya McCarthy

Reputation: 8829

This is exactly the point of environments in Conda. The packages of each are isolated from one another.

If you need a package in your py27 environment, install it using conda install vtk or pip install vtk while in the py27 environment.

Same goes for gdal: install it in the environment where you need it.

Upvotes: 1

Related Questions