cannot import tensorflow (installed with anaconda) in Visual Studio IDE - visual-studio

Follow these steps, I successfully installed Tensorflow 1.0.0 of GPU version on my win10 laptop, using anaconda virtual environment (I know little about this, just follow the tips)
I run the HelloWorld code in interactive mode like this:
activate tensorflow
python
import tensorflow as tf
# ...
However, I cannot run it when I write in anaconda's editor or Visual Studio 2015 (community edition). It says
no module named tensorflow
My config in VS is:
pic
So, can anyone give some tips on how to code tensorflow program happily in VS? Thx!

You will have to create an environment in Anaconda using the following command.
conda create -n tf tensorflow
Navigate to Anaconda -> Environments -> you will see tf environment. Select that, then launch VS code.
If you need other packages installed into the same environment you can use the following command. (Eg: to install pytest)
conda install -n tf pytest

Related

Can Jupyter Notebook run on Windows 10

I installed Jupyter Notebook on Windows 10. But I got an error when launching it in Visual Studio Code as:
jupyter : The term 'jupyter' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
After searching online, I decided to install Anaconda first and run Jupyter from it. But launching it from Anaconda was directed to a web address. It looks like Jupyter is only a web application.
I wonder if it is possible to run the Jupyter Notebook as a desktop application on Windows.
There is a JupyterLab Desktop App, see here and here. I don't know how old of a version of Windows works for it.
Rest was built from discussion in comments:
On Jupyter with VS Code:
Jupyter itself works with VScode to run Jupyter notebooks in VScode. You wouldn't need the JupyterLab Desktop App in that case. You do need Jupyter though. See here if you are interested in using Jupyter notebooks in VSCode.
On installing packages that worked before installed Anaconda:
The easiest solution would be to reinstall them. It is possible you could add the already installed ones to your path, but if you have room it is easiest to keep your Anaconda installed stuff where it is and separate from what you had. The easiest way to sort where to install them is to let Jupyter handle it. For example, if you want to work with Pandas in a notebook, in that notebook run %conda install -c anaconda pandas, based on here and the magic install command. For the packages that conda cannot install, and only for those, use %pip install <package_name>.
You can delete the install commands out of the notebook after if you want. You may just want to comment them out so you remember. For the short term you are fine re-running the commands because if the package is already installed by conda or pip it won't get reinstalled; however, if the package gets a new release and you aren't specifying versions, you'll get the latest when that install command next runs and if there is an error or incompatibility, then you'll have caused yourself an issue you could have avoided.

Installing a package that require C++ on pycharm (windows) using pip

I am developing a program in Python on Windows 10 using Pycharm. In this program I need to import this Python package that uses pip to be installed.
Following the standard procedure to install with pip on Pycharm I get an error:
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
The url gets me to an abandoned website but I finally found a way to install Visual C++ building tools (there).
Unfortunately I still have the same error.
I also upgraded the pip version to 18.1, in case the outdated version was to blame, but it didn't change anything.
What do I need to do for Pycharm to recognize my installation of Visual C++?
EDIT: This question is not the same as other questions that don't involve using Pycharm. Please take this into consideration while answering.
you don't have to use pip, there is very sophisticated way to install packages in pycharm.
In your pycharm, go to File>Settings>Project:[your-project-name]>Project Interpreter:
Click on the + sign:
and look for your package, in our condition ie. numpy. and click on install.
viola problem solved

How to install PyGObject in Anaconda under Windows 10?

I tried to run this simple code, which is about GUI programming in python usinh Python GTK+ 3:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
I have anaconda 5.2 installed with Python 3.6 under Windows 10, and I get this error:
import gi
ImportError: No module named 'gi'
Even if I install anaconda 4.2 with Python 3.5 I get the same error.
I could not figure out how to install gi, which is apparently part of PyGObject.
using pip install PyGObject results in an error:
Failed building wheel for PyGObject
Can anybody help?
As I explain in this answer there are two ways (afaik) to install PyGObject in Windows.
If you use the .exe installer you'll be restricted to Python 3.4. I've never used it with Anaconda, but the installer (before automatically checking for Python interpreter installations) lets you select "portable" installations of the interpreter (I believe this might be the way to point to a virtual environment interpreter, maybe a conda installed interpreter, I've never used it though). You can try and let it try to find your interpreter automatically and if it doesn't then you can cancel the install and re try with the "portable" approach.
If you use MSYS2 I really don't know how you can make it work. You'll have to use the included pacman instead of Anaconda to manage your packages, so I don't know if this is what you want.

Installing sIpopt on anaconda environment

I am currently working on a project using an environment within anaconda (my OS is Windows). My current environment already has IPOPT installed via the anaconda cloud. Now, I am trying to install sIPOPT (a toolbox for IPOPT, not to be mistaken with IPOPT itself), available on: https://www.coin-or.org/Ipopt/documentation/node33.html.
I am trying to install sIPOPT within the same anaconda environment that I am currently using for my project. Normally, I would proceed with using conda to install packages into my environments. However, I failed to find a channel to install sIPOPT via conda, or pip.
The instructions on installation of sIPOPT only gave instructions to build the package using the linux environment, which I am not familiar with. I am now assuming that if I installed a unix-like environment like Cygwin, I would be able to install sIPOPT to my anaconda environment.
My question is: have any of you done anything similar to this? Is it possible to install sIPOPT via Cygwin to an existing conda environment with Ipopt already installed?
Many thanks! :)

Tensorflow import error (Windows10) (python3.5.3) (tensorflow-gpu #243 nightly binary)

Environment:
Windows10
Python 3.5.3 64bit
CUDA Toolkit 8.0
cuDNN v5.1(extracted to Toolkit8.0 files)
Visual Studio Community 2015
Nightly binary#243 Tensorflow GPU version (pip install tensorflow_gpu-1.2.1-cp35-cp35m-win_amd64.whl)
The package has not been installed correctly, and the file _pywrap_tensorflow.pyd is not present in the C:\...\Lib\site-packages\tensorflow\python
After I got nearly the same error as #5949, I tried mrry's tensorflow_self_check.py.
The output is:
ERROR: Failed to import the TensorFlow module.
Python version is 3.5.
TensorFlow is installed at: C:\Python\Python35\lib\site-packages\tensorflow
All required DLLs are present. Please open an issue on the
TensorFlow GitHub page: github.com/tensorflow/tensorflow/issues
However, I can import the tensorflow successfully if I use the below version:
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl
So, what's wrong the tensorflow_gpu-1.2.1 version?
I really hope someone can help me solve it completely. Thank you!
I would suggest to use Anaconda for the windows, if you want to try tensorflow. The number of issues is very less.
https://www.tensorflow.org/install/install_windows
But if you really want to work without anaconda.
Check your path to Cuda, Cudnn and python.
Ensure that cudnn is v5.1
TensorFlow 1.3 or later requires cuDNN 6.
Installing the Microsoft Visual C++ 2015 Redistributable Update 3 (x64 version) can fix it.
Do let me know about after trying above steps.

Resources