Is Anaconda necessary to be installed to PC besides Jupyter Notebook? - python

I am new to Python. I am a very old R programmer. One of my PhD courses is performed via Python.
So, I installed Jupyter Notebook; I wrote simple "Hello World" in Jupyter Notebook. I wonder whether I must install Anaconda or not?
I ask this because: I looked at Anaconda's IDE in youtube, and it shows RStudio, Jupyter Notebook, etc. in a bundled manner. In RStudio, one can perform all the package handlings within RStudio.
So, I wondered is there a way to install python packages within Jupyter Notebook, or should I really install Anaconda? What is the benefit of installing Anaconda (besides Jupyter Notebook)?

The packages in python are generally installed with "pip" (or "conda") in the terminal and are then available regardless where you run your script from. Assuming you don't have multiple python versions set up on your PC, they should then all be available in your jupyter-notebook also.
If you don't want to open another window to do this, you can also run BASH code from Jupyter itself, just start the line with an exclamation mark (!)
i.e.
!pip install pandas
The benefits of Anaconda are that it bundles everything you need to at least start your more basic projects (python release, basic packages, IDE) and that you can set-up project-specific environments that do not interfere with your system-wide package installations.

Python packages are not installed with python functions, like it would be the case in R with install.packages("package name"). Instead, an external package manager usually is used to install and possibly compile the package files to a directory where python can import it from.
Anaconda offers (among others) the package manager conda. Most popular is pip. Some Linux distributions also offer python packages via their package manager (e.g. apt on Debian/Ubuntu). All these package managers download packages from their own repositories, so conda install numpy, pip install numpy and apt install python3-numpy all install a package numpy, but from different sources and in possibly different versions.
Jupyter Notebook is a programming environment, where you can execute shell commands with !command, so depending on the system where the Jupyter server is running, you can use !pip install numpy, !conda install numpy or other commands as cells in the Jupyter Notebook you are working in. This will run the command in a shell.
That graphical menu with Jupyter, RStudio etc. you describe is the program "Anaconda Navigator", which is installed with Anaconda. Jupyter is just a Python library, which is pre-installed with Anaconda, but can also be installed via pip, apt and other package managers.

Like Virtualenv, Anaconda also uses the concept of creating environments so as to isolate different libraries and versions. Anaconda also introduces its own package manager, called conda, from where you can install libraries.
Additionally, Anaconda still has the useful interaction with pip that allows you to install any additional libraries which are not available in the Anaconda package manager.
It is a good option for setting up of a better environment for working with jupyter.

Related

Installing/using p5py/p5 under Anaconda

I have coded some projects in processing that I would like to continue in python under the python port p5py/p5.
I am using Anaconda as my Python environment, but couldn't find a way of installing p5py/p5 via conda; installing p5py/p5 via pip works, but the library can't be imported into within Spyder in the Anaconda environment.
I have been able to install all libraries on which p5py/p5 depends from within Anaconda, which makes it a bit frustrating that I can't get p5 installed.
I would therefore appreciate any tips for making p5py/p5 importable from with the Anaconda environment.
As performance is currently not a pressing issue to me so suboptimal workarounds would also be of help.

What is the difference between <package name> and python-<package name>?

I want to downgrade tornado to a previous version because the new one causes an error according to the answers here: Jupyter notebook kernel not connecting. I am on Ubuntu, in a virtual environment.
To check the current version of it, I used pip freeze and got this: tornado==6.0.1. When I use apt-cache policy tornado the output is: "Unable to locate package tornado". When I type apt-cache policy python-tornado the output is "python-tornado: Installed: 4.5.3-1".
How do I proceed from here? My ultimate goal is to make the jupyter notebook run, and I need to figure out this tornado module for that. What is the difference between tornado and python-tornado? Which one I should care about?
One of those names is the actual package name under which it is published to the Python Package Index (PyPI), which is the namespace that pip deals in.
The other is the name as set by your Ubuntu operating system, and given the version string, I am guessing that you are using Ubuntu 18.04 Bionic Beaver. Ubuntu uses a strict naming convention, where all Python packages must start with a python- prefix. These packages are managed and installed by your OS package manager.
How to proceed depends on your Jupyter setup. If it is installed and running from a virtualenv, then you can use the pip command when the virtualenv is active to alter versions there. Take into account that using pip should already ensure you are getting compatible versions installed; you could try to upgrade jupyter if tornado was upgraded independently.
If you are using the Ubuntu-managed jupyter package then there too the package manager should take care of matching versions.
However, if you you are using a virtualenv that still has access to the OS-mananged jupyter system while locally only tornado is installed, then you want to add jupyter to your virtualenv to mask the system version, which is too old.

Does Anaconda reinstall all the packages like(numpy, pandas, pycuda etc) even if I had installed them earlier separately with python in Ubuntu 18.04?

As I already have quite a lot of packages installed without installing Anaconda will I have to reinstall them again separately? Or are they accessible in Anaconda environment because I have them preinstalled? There is a similar question which has the answer suggesting installing only miniconda but in my case Anaconda is necessary.
No, anaconda uses completely different environments and whatever downgrading it does, it does it within it's own environments. So, if you are using anaconda environments within your applications, you don't need to reinstall anything but if you are using another environment (like pip only) you need to make sure you have installed all the necessary packages there as well.
Also, if a package is installed using pip and not installed in conda, it will automatically switch to pip so there is no problem there.

Is there any benefit of using Anaconda for PyCharm?

Is there any benefit of using Anaconda for PyCharm instead of the standard python distribution for PyCharm?
Using Anaconda instead of standard Python will benefit you as Anaconda comes with preinstalled packages. A lot of time will be saved there since installing various packages and making them run gets irritating sometimes.
Also, since it will have preinstalled packages, it can be heavy for your system. You can try miniconda as an alternative where you install packages when required. It is still better than having Python only. You can even install Anaconda by using conda install anaconda
Pip installation of Python packages sometimes may cause few problems to the user and you need to constantly update the pip as well before installing any other python packages via pip. So using Anaconda will be a benefit in this case.

How do you install Tensorflow on Windows?

I am trying to install Tensorflow on Windows.
I have Anaconda 4.2.0. I tried running
conda create -n tensorflow python=3.5
in my command prompt. This seemed to do something, but I'm not sure what this accomplished. It created a folder within the Anaconda3 program in my username folder.
This folder is filled with the following content:
Over the summer, I used mainly Jupyter Notebooks to do my python coding. Within this environment, there is a tab marked Condas
So it looks like I should be able to switch to the Tensorflow environment. But this doesn't work when I try to switch, there is no option to change my kernel to a Tensorflow one.
I tried running
conda search tensorflow
But nothing appears.
I'm not sure what to do. I asked a few grad students in my economics research group, but they weren't sure what to do either.
My Question
How do I properly install Tensorflow on Windows?
The syntax of the command is conda create -n <name_of_new_env> <packages>. As a result, you created a clean environment named tensorflow with only Python 3.5 installed. Since conda search tensorflow returned nothing, you will have to use pip or some other method of installing the package. Since there is spotty official support for Windows, the conda-forge package (CPU only) at https://github.com/conda-forge/tensorflow-feedstock is probably the best way.
People have also reported success installing Tensorflow with docker, if you have docker set up already.
I was able to run it under the Windows 10 linux subsystem (https://msdn.microsoft.com/en-us/commandline/wsl/install_guide)
Which is basically a linux environment within windows.
The latest tensorflow version (0.12) added windows support
https://www.tensorflow.org/get_started/os_setup#pip_installation_on_windows
just run:
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl
(the url is for the specific version - you will need to change it for future versions or other setups)
An Anaconda environment isolates itself completely with the outer world, so all the packages you installed outside the virtualenv is nothing in the virtualenv, if you want to use Tensorflow in the environment(seems like the only way with Anaconda), use activate tensorflow command and install the packages you want seperately.
pip provides an easy method to install tensorflow on windows machine.
use the following pip command
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl
Tensorflow only support python3.5 x64 bit on windows machines and it requires that you install Visual C++ 2015 redistributable (x64 version) to be able to import tensorflow

Categories

Resources