1

I've installed a few different libraries using Anaconda but whenever I try launching in VS Code it doesn't recognize the libraries even when running through the Conda environment.

Anaconda Navigator

Then say I click the Jupyter Launch button and create a new .py file & I can import Numpy all good and well enter image description here

But I want to launch in VS Code say, so I launch from the Navigator and I'm getting an error?enter image description here

Correct env too enter image description here

Andre Fu
  • 400
  • 1
  • 4
  • 16
  • 1
    You got invalid syntax error. Missing comma before `dtype`. – 9dogs Jun 20 '18 at 16:27
  • @9dogs sorry yes, I reuploaded the "No module" error now – Andre Fu Jun 20 '18 at 17:23
  • You can try selecting different interpreter. In VSCode press `CTRL+SHIFT+p`, command palette will open. Type 'select interpreter' and press ENTER. Then choose one with `Anaconda` with it (or your virtualenv name with `numpy` installed). – 9dogs Jun 21 '18 at 09:51
  • @9dogs I tried that got a 'pyhton.setinterpreter' error; uninstalled VS Code and reinstalled it - works but still getting same ImportError – Andre Fu Jun 23 '18 at 04:16
  • I reinstalled everything & installed anaconda with the ADD TO PATH setting but still not working – Andre Fu Jun 23 '18 at 05:04
  • Check my answer [here](https://stackoverflow.com/questions/50178109/python-modules-installing-properly-but-dont-exist-in-editors/50178345#50178345) I believe it will solve your issue – Morse Jun 23 '18 at 19:57

1 Answers1

0

Install Anaconda packages and libraries in your Linux subsystem on Windows. Your integrated terminal is a Bash shell on Windows 10, which does not have any installed package and library for your code.

Try sudo apt-get install python-pip and pip install numpy or sudo apt-get install python3-pip and pip3 install numpy on integrated terminal in vscode.

If this solves your module error for numpy, try the following lines to install conda in your Linux subsystem, or you can just use pip to manage your python packages and libraries.

curl -O https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh
bash Anaconda3-5.2.0-Linux-x86_64.sh

This will give the following output and type yes to this:

Do you wish the installer to prepend the Anaconda3 install location
to PATH in your /home/[username]/.bashrc ? [yes|no]

Then, source your .bashrc:

source ~/.bashrc

Now, you can use command conda to install packages. Try to install packages and libraries you want with the following command:

conda install [package name]

Or you can check what is installed on your conda with the following command:

conda list
YoungChoi
  • 324
  • 4
  • 14
  • great, but I'm getting errors when trying to [pip install packages](https://imgur.com/oBITBqD) – Andre Fu Jun 23 '18 at 20:29
  • 1
    try `python3 test.py`. Because you installed your package with pip3, numpy package is installed for python3. – YoungChoi Jun 23 '18 at 20:31
  • Ideal, I'm trying to Install conda to the linux subsystem now but it won't let me install to .bashrc only to `/home/andre/Anaconda3` that should be fine right? – Andre Fu Jun 23 '18 at 20:46
  • Of course! Your Anaconda3 should be installed in /home/andre/Anaconda3 and the installer will prepend that location to PATH in your .bashrc. .bashrc and `source ~/.bashrc` let you use conda in the terminal. – YoungChoi Jun 23 '18 at 20:49
  • This worked well, but its still [not recognizing the conda packages](https://imgur.com/loWzGBe) Should I just forget about conda entirely and keep installing via pip3? – Andre Fu Jun 23 '18 at 21:10
  • You should install packages via conda or pip3, because Linux subsystem does not share any packages from your windows machine. – YoungChoi Jun 23 '18 at 21:11