How to Upload From Anaconda Python 2.7 to 3
Python Environment Direction with Conda (Python ii + 3, Using Multiple Versions of Python)
Coming beyond an ImportError similar to the one in the image beneath can be abrasive.
Luckily, Anaconda makes information technology easy to install packages with the package manager functionality of conda. In case you lot need a refresher, a package director is a tool which automates the process of installing, updating, and removing packages. While Conda is a package and environment director, let'southward first review the parcel manager functionality of conda and then focus on the surroundings manager functionality.
Install Packages
Open a control prompt/anaconda prompt (windows) or a final (mac/linux) and run the control below. You can be substitute numpy
for whatever parcel you desire to install.
conda install numpy
Uninstall Packages
Run the control below to uninstall a packet. Yous tin can be substitute numpy
for whatever package you want to uninstall.
conda uninstall numpy
Update Packages
Run the command below to update a package. You tin can exist substitute scikit-acquire
for whatsoever bundle you want to update.
conda update scikit-learn
Conda vs Pip
Pip is a Python parcel managing director which stands for "Pip Installs Packages" that is usually coupled with virtualenv (a tool for creating isolated environments).
Well-nigh of the fourth dimension (with some exceptions) there isn't much of a difference between installing packages through conda or through pip. This is because pip packages are also installable into Conda environments.
conda install numpy
pip install numpy
This isn't a discussion on conda vs pip every bit Jake VanderPlas covered information technology pretty extensively, but why y'all can mostly install packages through either pip or conda.
Why yous Demand Multiple Conda/Python Environments.
Say you have multiple projects and they all rely on a library (Pandas, Numpy etc). If you upgrade 1 package information technology could break your other projects relying on old versions of the packet as the old project'due south syntax could become deprecated or obsolete. What should you practise? Ready a virtual environment. Information technology allows you to split up out packages, dependencies and versions yous are going to apply from project to project.
A mutual use of virtual environments for python users is having separate Python two and 3 environments. For example, a couple of my classmates at UC San Diego recently started a machine learning class where ane professor sets assignments in Python 3. Withal, another class has a professor who sets assignments in Python 2. Consequently, they have to frequently switch between python 2 and 3 in their dissimilar class projects. With that, let's go into conda environment commands. I recommend you open the video in a separate tab to scout the commands in action.
Create a New Environment
The control below creates a conda environment named subscribe
in python version 3.6. You can exist substitute subscribe
for any y'all desire to name your environment.
conda create --name subscribe python=three.6
Continue in mind that yous will need to install additional packages within that surround once you actuate (enter) that surroundings. The packages you lot have in your root environs are non necessarily the ones you will accept in your new environs unless y'all install them.
You lot can besides create an environment with multiple packages in it. This likewise gives y'all the pick to install boosted packages later if you demand them.
conda create --name chooseAnotherName python=3.6 numpy pandas scipy
Enter an Environment
If the proper name of your surroundings is not subscribe
, you will need to substitute subscribe
for the name of your environment.
Windows:
activate subscribe
Mac:
source actuate subscribe
Exit an Environment
If the name of your environs is not subscribe
, yous will need to substitute subscribe
for the name of your environs.
Windows:
deactivate subscribe
Mac:
source deactivate subscribe
List your Environments
This control shows you lot all the This is a really helpful control to run across what environments you have, but also to see what conda environs you are in.
conda env listing
Remove an Environment
If the proper name of your environs you desire to remove is not subscribe
, y'all volition need to substitute subscribe
for the name of your surroundings yous want to remove.
conda env remove --proper name subscribe
If y'all accept questions on this part, delight refer to the documentation, leave a comment or refer to the video above.
Using Both Python two.x and Python 3.x Environments in IPython Notebook
While this department of the mail was largely taken and improved from stackoverflow, I feel like information technology is important to go over how and become over some technical bug people run into. The master idea is to accept multiple ipython kernels. The package nb_conda_kernels will automatically discover different conda environments with notebook kernels and automatically register them.
- Make sure you lot accept anaconda 4.1.0 or college. Open a new last and bank check your conda version by typing
if you are below anaconda 4.1.0, type conda update conda
2. Next we check to see if we have the library nb_conda_kernels by typing
3. If you don't encounter nb_conda_kernels type
iv. If you lot are using Python 2 and want a split up Python 3 environment please blazon the following
If you are using Python 3 and want a dissever Python 2 environment, you could type the following.
5. Close your concluding and open upwards a new terminal. type jupyter notebook
half-dozen. Click new and yous will meet your virtual environment listed.
Please let me know if y'all accept whatever questions either hither or in the youtube video comments!
howardliferairipea.blogspot.com
Source: https://towardsdatascience.com/environment-management-with-conda-python-2-3-b9961a8a5097
0 Response to "How to Upload From Anaconda Python 2.7 to 3"
Post a Comment