Bill O
Bill O

Reputation: 400

import cntk works in VS2017 "python environment" but not in "python project"

I'm trying to use CNTK in Python/VS2017. I'm experienced in VS but new to Python and CNTK.

I've installed CNTK into Anaconda 4.1.1 and I've created a custom Anaconda environment pointing to C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py35.

If I open an Interactive Window from the "Python Environments" list in VS2017, I can import CNTK.

However, if I create an empty Python project in VS2017, then open an Interactive Window from the same Anaconda environment shown in the project "Python Environments" list, I get a "module not found".

Any help is appreciated, Bill

    Traceback (most recent call last):
  File "C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py35\lib\site-packages\cntk\cntk_py.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'cntk._cntk_py'

works in Python Environments

but not in a Python project

Upvotes: 1

Views: 201

Answers (1)

Bill O
Bill O

Reputation: 400

This seems like a flaw in VS2017 to me, but this is a solution, if not a good one.

In the Python project properties I changed the Working director from "." to the full path of the Anaconda environment.

enter image description here

Upvotes: 1

Related Questions