I installed the latest Anaconda and installed it with default values.
After that, I tried which python and it's giving me correct python paths for Anaconda5.1 Python2.7 versions ~/anaconda2/bin.
Now when I create a virtual environment using the following command:
conda create -n new_env python=2.7 opencv numpy pandas
&
source activate new_env
When I do which python now I get the new virtual environment python ~/anaconda2/envs/new_env/bin/python which is good. But when I do which conda I get the base anaconda conda ~/anaconda2/bin/conda not the virtual environment conda path. In previous versions, it wasn't like this.
Am I missing something here?
p.s. I tried with Anaconda5.1 for Python3.6 also, the same result.
Related
I recently installed Anaconda in my Windows. I did that to use some packages from some specific channels required by an application that is using Python 3.5 as its scripting language.
I adjusted my PATH variable to use Conda, pointing to the Python environment of the particular program, but now I would like to use Conda as well for a different Python installation that I have on my Windows.
When installing Anaconda then it isn't asking for a Python version to be related to. So, how can I use Conda to install into the other Python installation. Both Python installations are 'physical' installations - not virtual in any way.
Uninstall the other python installation and create different conda environments, that is what conda is great at.
Using conda from your anaconda installation to manage packages from another, independent python installation is not possible and not very feasible.
Something like this could serve your needs:
Create one env for python 3.5 conda create -n py35 python=3.5
Create one env for some other python version you would like to use, e.g. 3.6: conda create -n py36 python=3.6
Use conda activate py35, conda deactivate, conda activate py36 to switch between your virtual environments.
I want to install Anaconda with Python Version 3.6.5. If I install Anaconda3-5.2.0, It install Python 3.5.1. Where to download the Anaconda with Python 3.6.5. The Big Data Scripts work only with Anaconda Python 3.6.5.
Anaconda Downloads
The Anaconda distribution with Python 3.6.5 was version 5.2.0.1 You can download this from the Anaconda distribution archive. If you do install from this, then make sure to update Conda immediately after installation:
conda update conda
However, I strongly recommend the following alternate solution as better practice.
Miniconda + Anaconda environment
Reasoning
What is installed in the base environment is relatively fixed once installed. Ultimately, you don't want to mess with your base environment, so best practice is to have the latest version there. Fortunately, you don't have to install a full Anaconda distribution, but rather can use a lightweight Miniconda (or Miniforge) distribution and create a secondary environment for the purpose of having an Anaconda Python 3.6.5 distribution. In the long run this will give you better stability.
Steps
Download and install Miniconda or a Miniforge variant. Once that is working...
Create your Anaconda env:
conda create --name my_env -c anaconda python=3.6.5 anaconda=5.2.0
Use your new isolated env:
conda activate my_env
[1] I determined this by running conda create -n foo --dry-run -c anaconda python=3.6.5 anaconda and then examining the version of the anaconda package that Conda ended up with in the solve.
Also try
conda install python=3.6.5
but you may encounter some incompatibility issues with other packages.
Alternatively, you may want to try creating a new environment. From the anaconda prompt, create a custom environment and specify the repository channel to find the version
conda create --name py365 python=3.6.5 --channel conda-forge
Activate the new environment
conda activate py365
However, the activation will not be permanent, and you will need to activate each time you start the anaconda prompt.
In your anaconda prompt, you can manually update your python to the latest version with :
conda update python
In case you are not familiar with it, anaconda prompt is installed to your computer when you install anaconda. Just make a search for it on your computer.
You can refer to this post : How do I upgrade to Python 3.6 with conda?
I have Conda 4.7.11 and system python 3.7.3 (base) on MacBook. Whenever I try to install new packages on the environment that I have created, Conda installs them on the base instead.
I have activated the environment and when I type python on the Terminal, I get the correct python version of my env (3.6.9). Also, which python points me to the correct python path: /anaconda3/envs/Bayesian_Models/bin/python
But, if I type conda info, when my env is active, then I get this (python 3.7.3):
Workaround
I'm not sure how to fix the issue permanently, but specifying the env using the --name|-n tag could get around the problem:
conda install -n Bayesian_Models foo_package
I have a python 3.4 environment with very specific packages installed. Is there a straight forward way to create an anaconda environment will all the same packages without creating a python environment then manually installing the packages. e.g..
conda create -n myenv python=3.4
conda activate myenv
conda install beautifulsoup4==4.6.1
I'd like to do this as i want to share a python script and make it as easy as possible for others to run it.
These are all the packages installed in my python3.4 environment
'altgraph==0.16.1',
'asn1crypto==0.24.0',
'beautifulsoup4==4.6.1',
'certifi==2018.4.16',
'cffi==1.11.5',
'chardet==3.0.4',
'configargparse==0.13.0',
'cryptography==2.3',
'defusedxml==0.5.0',
'dis3==0.1.3',
'future==0.17.1',
'h5py==2.8.0',
'idna==2.7',
'jira==2.0.0',
'macholib==1.11',
'numpy==1.15.3',
'oauthlib==2.1.0',
'pbr==4.2.0',
'pefile==2018.8.8',
'pycparser==2.18',
'pyinstaller==3.4',
'pyjwt==1.6.4',
'pyqt4==4.11.4',
'pywin32-ctypes==0.2.0',
'pywin32==220',
'regex==2018.07.11',
'requests-oauthlib==1.0.0',
'requests-toolbelt==0.8.0',
'requests==2.19.1',
'six==1.11.0',
'urllib3==1.23',
'xmltodict==0.11.0'
conda-env is your friend:
conda-env export -n orig > orig.yml
where orig is the name of the environment you want to clone, followed by
conda-env create -n new -f=orig.yml
where new is the new name of the copy. The file orig.yml contains everything about the environment you want to copy: dependencies, installed packages incl. version, and such.
I want to work with the python package holopy. Apparently you have to use conda to install it, so I first installed Anaconda 4.2.0 (since I'm using Python 3.5). I opened the virtual environment I normally use and installed holopy as they recommend on the official site:
conda install -c conda-forge holopy
Afterwards, when in the virtual environment I type conda list, holopy shows up. But when I type python3 and then import holopy, it says package not found. It does however work when I leave the virtual environment. I need it in the virtual environment though, how can I do that?
I'm not sure how well anaconda and virtual environments i.e.venv work together. If you're using anaconda anyway then I highly recommend using anaconda environments. Please go through this short tutorial about anaconda environments - you won't regret it.
Why it didn't work for you?
The conda command is available only in the base anaconda environment. So when you run the command - conda insall -c conda-forge holopy, it installed holopy in the base anaconda environment and it won't be available to you in your venv.
After looking at the documentation of holopy it seems probable that when they said virtual environment they actually meant anaconda virtual environment. Therefore the solution is to first create an anaconda virtual environment called holopy-env and then run the command conda install -n holopy-env -c conda-forge holopy.
A better way of doing things with Anaconda
I will also give you a quick and clean example of how to create an environment using anaconda. If you're using Anaconda then it would be wise to use it's environment management tools. Create an environment.yml file with the following contents:
environment.yml using conda-forge/holopy & python 3.6
name: holopy-env # any name for the environment
channels:
- conda-forge
dependencies: # everything under this, installed by conda
- python=3.6
- holopy
- pip: # everything under this, installed by pip
- future
How to install the environment?
conda create --force -f environment.yml
How to activate the environment?
source activate opencv-env
After activating the environment
You should be able to import holopy
Install pip packages using pip install <package>
Install conda packages using conda install -n holopy-env -c CHANNEL <package>
conda is a packaging tool and installer that aims to do more than what pip can do; handle library dependencies outside of the Python packages as well as the Python packages themselves. Conda also creates a virtual environment, like virtualenv does. For creating virtualenv with conda, use the following command:-
conda create -n yourenvname python=x.x anaconda
Use the following to activate the virtualenv in conda
source activate yourenvname
Then, you can install the packages in virtualenv using conda as:-
conda install -n yourenvname [package]
To Deactivate use:-
source deactivate
And to delete a no longer needed virtualenv, use :-
conda remove -n yourenvname -all
I know this is a bit late, but you don't need to use conda to install HoloPy. This is just the least technical option. Otherwise, you need to be able to compile HoloPy's fortran components yourself, which is fairly straightforward on Unix-based systems but complicated on Windows. Instructions can be found in HoloPy's documentation at https://holopy.readthedocs.io/en/latest/users/dev_tutorial.html.
We are also working on putting together a singularity container distribution of HoloPy. Let me know if this is of interest to you and I will make it a priority.