I am a beginner, and trying to run a package, Trimmomatic, that is located within the Anaconda environment. I have tried to extensively google how to actually run a program within the environment and I cannot find anything. I usually code in bash so this is all new to me. Any help would be fantastic!
I am able to load the environment:
module load anaconda/2-4.2.0_cent
source activate base
But I have no idea how to get the package to run.
Thanks in advance!
When you install anaconda you're given the option to add it to your $PATH, and the default option is no.
Putting the anaconda directory in your path is a necessary first step, as this allows you to use the conda command which gets used a bunch.
I'm going to assume you installed anaconda to /home/me/anaconda3/. If you installed Anaconda2, change anaconda3/ to anaconda2/.
First off, do the following:
~$ [export] PATH="/home/me/anaconda3/bin:$PATH"
~$ conda --version
conda <X.Y.Z>
After you've confirmed conda is in your path, you'll already have access to the base env, but you can double-check with:
~$ conda env list
# conda environments:
#
base * /home/me/anaconda3
~$ which python
/home/me/anaconda3/bin/python
If you want to create a new venv, conda makes that extremely easy:
conda create python=2.7 -n py27env
Solving environment: done
## Package Plan ##
environment location: /home/me/anaconda3/envs/py27env
added / updated specs:
- python=2.7
The following packages will be downloaded:
package | build
---------------------------|-----------------
wheel-0.31.1 | py27_0 62 KB
python-2.7.15 | h1571d57_0 12.1 MB
certifi-2018.8.13 | py27_0 139 KB
pip-10.0.1 | py27_0 1.7 MB
setuptools-40.0.0 | py27_0 583 KB
------------------------------------------------------------
Total: 14.6 MB
The following NEW packages will be INSTALLED:
ca-certificates: 2018.03.07-0
certifi: 2018.8.13-py27_0
ncurses: 6.1-hfffgggg474d3e_0
openssl: 1.0.2p-h14c325_0
pip: 10.0.1-py27_0
python: 2.7.15-h1571e57_0
readline: 7.0-ha6073c88_4
setuptools: 40.0.0-py27_0
wheel: 0.31.1-py27_0
zlib: 1.2.11-ha838bed_2
...
Proceed ([y]/n)?
Now just press yes, conda will do it's thing, and you'll get a little prompt about how to use source activate, and you're good to go!
For completeness, here's a couple more lines of bash to double-check:
~$ source activate py27env
(py27env) ~$ which python
/home/me/anaconda3/envs/py27env/bin/python
(py27env) ~$ conda env list
~$ conda env list
# conda environments:
#
base /home/me/anaconda3
py27env * /home/me/anaconda3/envs/py27env
Hope this helps!
Type conda list to verify that the package you want to run is installed in the current environment. If you are not in the correct environment, type conda activate env_name (where env_name is the name of the environment you want to activate).
If the package you want to run is listed when you type conda list, then you can run it directly. Try by just typing the package name. If not, try python -m package_name.
Related
So, I have a python project where all my tests run but then I do:
conda install -y conda-pack
which succeeds and when I run:
conda-pack
I get a lengthy complaint:
Collecting packages...
CondaPackError:
Files managed by conda were found to have been deleted/overwritten in the
following packages:
- conda-pack 0.6.0:
lib/python3.1/site-packages/conda_pack-0.6.0.dist-info/INSTALLER
lib/python3.1/site-packages/conda_pack-0.6.0.dist-info/LICENSE.txt
lib/python3.1/site-packages/conda_pack-0.6.0.dist-info/METADATA
+ 19 others
- types-requests 2.26.0:
lib/python3.1/site-packages/requests-stubs/METADATA.toml
lib/python3.1/site-packages/requests-stubs/__init__.pyi
lib/python3.1/site-packages/requests-stubs/adapters.pyi
+ 41 others
- jsonschema 4.2.1:
lib/python3.1/site-packages/jsonschema-4.2.1.dist-info/COPYING
lib/python3.1/site-packages/jsonschema-4.2.1.dist-info/INSTALLER
lib/python3.1/site-packages/jsonschema-4.2.1.dist-info/METADATA
+ 39 others
- types-setuptools 57.4.2:
lib/python3.1/site-packages/pkg_resources-stubs/METADATA.toml
lib/python3.1/site-packages/pkg_resources-stubs/__init__.pyi
lib/python3.1/site-packages/pkg_resources-stubs/py31compat.pyi
+ 56 others
<snip>
I see no issues in conda list and I can still run my tests. I see no issues with my environment. Ideas?
This should be related to this issue: https://github.com/conda/conda-pack/issues/198
The root cause is that the image is trying to use python3.10 and conda-pack parse it as python3.1.
They claimed to have fixed it in conda-pack 0.7.0 (release note) but I was using 0.7.0 and still see this problem.
One workaround is to specify another python version in a new env:
conda create -n new_env python=3.9 ${other_packages}
conda install conda-pack
conda-pack -n new_env ${your_other_options}
I think the problem is still there in conda-pack 0.7.0 in the unix-world and will only appear for python 3.10 and upward. It might be dependent on the conda version, but many users do not have the rights to update conda (as is the case for me). Reason are the symbolic links generated by python, which direct python 3.1 packages/programs to python 3.10. Conda-pack does not understand that correctly und searches for python3.1 files.
Solution is a) to update conda if possible b) if that fails to exclude those python3.1 references (running conda-pack in the environment, say myenv, you want to pack - will generate myenv.tar.gz):
conda-pack -f --ignore-missing-files --exclude lib/python3.1
I have miniconda 3 installation and want to create conda environment with Python 3.4. I used the command: conda create -n myenv python=3.4 and get the error:
PackagesNotFoundError: The following packages are not available from current channels:
- python=3.4
I tried to change the version to 3.7, typing conda create -n myenv python=3.7
There was no error with version 3.7. So the problem seems to be related with the older versions of python.
This is the full output with the error message:
Collecting package metadata (current_repodata.json): done
Solving environment: failed
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- python=3.4
Current channels:
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
The reason you are not able to install python 3.4 package is that it is not available in the default channel of anaconda from where you are trying to install.
However, I just checked that it is available in the conda-forge channel. So, it can be installed as below:
conda create -n myenv python=3.4 -c conda-forge
It seems to me that Python 3.4 is not available in any of your listed repositories. I've tried to create an environment with it in Anaconda and it worked. Try to update Miniconda first:
conda update -n base -c defaults conda
If it does not work, look for a repository containing Python 3.4 and add it to your list of repositories.
what you can try is update and search python interpreter versions:
Step1:
conda update conda
Step2:
conda search "^python$"
It will list all the available versions:
python 3.4.0 0 defaults
python 3.4.1 0 defaults
python 3.4.1 1 defaults
python 3.4.1 2 defaults
python 3.4.1 3 defaults
python 3.4.1 4 defaults
python 3.4.2 0 defaults
python 3.4.3 0 defaults
python 3.4.3 2 defaults
python 3.4.4 0 defaults
python 3.4.4 5 defaults
python 3.4.5 0 defaults
Then install based on the existing versions.
You can try this if its helpful..
open Anaconda Navigator
Go to Environment tab
Click on "+Create"
Choose your preference python package, give it name and save it.
Open Anaconda prompt and type (base) C:\User\XXXX > conda info --envs
You will your environment name therein
To activate that environment type (base) C:\User\XXXX > conda activate "your env. name"
You will find your environment been activated. And now line will show like ("your env. name")C:\User\XXXX >
Enjoy !
Wanted to add that if you've already created your conda virtual environment, you can always install Python after the fact using a simple conda install python command. So no need to delete the conda env and re-create it with the python explicitly specified.
I am relatively new to Python and trying to figure out how to set up my different implementations of Python. To run different packages, I have multiple installations of python 2.7 and 3.6, both 32-bit and 64-bit. For example, I run some GIS software that uses its own implementation of python (OSGEO4W) that I run from the installation location (32-bit Python 2.7). This python executable has a package (otbApplication), that doesn't really install from pip or conda. However, I mainly run python (also 32-bit Python 2.7) from Anaconda. When I am running from Anaconda, is there a way to have otbApplication and other libraries in OSGEO4W implementation of Python available?
Once you have anaconda up and running you can use following process to install anaconda equivalent of virtual environment.
Make sure you are able access anaconda from your current folder
(base) C:\Users>conda -V
conda 4.4.7
Lookup python version available to be installed.
long list, truncated here
(base) C:\Users>conda search "^python$"
Loading channels: done
Name Version Build Channel
python 2.6.8 5 defaults
|
|
|
python 3.6.4 h6538335_1 defaults
Create virtual environment with selected python version
(base) C:\Users>conda create -n testVirtualEnv python=3.6.4 anaconda
Solving environment: done
## Package Plan ##
environment location: C:\Anaconda3\envs\testVirtualEnv
added / updated specs:
- anaconda
- python=3.6.4
|
|
#
# To activate this environment, use
#
# $ conda activate testVirtualEnv
#
# To deactivate an active environment, use
#
# $ conda deactivate
Activate virtual environment
Notice context changed from (base) to (testVirtualEnv)
(base) C:\Users>conda activate testVirtualEnv
Test to check python version in virtual env.
(testVirtualEnv) C:\Users>python -V
Python 3.6.4 :: Anaconda custom (64-bit)
Install a package in virtual env
(testVirtualEnv) C:\Users>conda install -n testVirtualEnv openpyxl
Solving environment: done
## Package Plan ##
environment location: C:\Anaconda3\envs\testVirtualEnv
added / updated specs:
- openpyxl
|
|
Executing transaction: done
Deactivate running environment
Notice context changed to (base)
(testVirtualEnv) C:\Users>conda deactivate
(base) C:\Users>
Remove and delete virtual Env
(base) C:\Users>conda remove -n testVirtualEnv --all
Remove all packages in environment C:\Anaconda3\envs\testVirtualEnv
Proceed ([y]/n)? y
(base) C:\Users>
You can research further commands at official documentation site.
I have a .yml file that was saved by a colleague. I cannot recreate an environment with conda env create -f file.yml (both with anaconda and miniconda on Ubuntu, and with the official docker images of both)
I tried to add - conda-forge to the channels but that doesn't change anything, I still get:
Collecting pyspark==2.1.1
Could not find a version that satisfies the requirement pyspark==2.1.1 (from versions: )
No matching distribution found for pyspark==2.1.1
CondaValueError: pip returned an error.```
Whereas installing manually this package with pip or conda works.
Here are the yaml file contents:
name: stuff
channels:
- defaults
dependencies:
- pip=9.0.1=py36_1
- python=3.6.1=0
- setuptools=27.2.0=py36_0
- pip:
- pyspark==2.1.1
I think for now the guys from Continuum don't actively develop "conda env" anymore. So the recommendation is to use "conda create" directly instead. To share an environment with the exact package version you can simply export the active environment with:
conda list --explicit > my_environment.txt
and pipe the output of that to a file (in the example to "my_environment.txt"). Afterwards you can import the environment by giving it a name (in the example below "MyEnvironment") and the --file option with the exported environment:
conda create --name MyEnvironment --file my_environment.txt
If I run
ipython notebook
in terminal
it reports
Could not start notebook. Please install ipython-notebook
But I am sure the notebook is indeed install by
conda install ipython-notebook
because
conda install ipython-notebook
gives me
Fetching package metadata: ..
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/a/anaconda:
#
ipython-notebook 2.3.1 py27_0
so I guess the command line bunded to a wrong location.
So how can I figure out which binary or directory the command line pointed to?
I am not terribly familar with conda, but looking at the description tells me it is some soft of package management tool. One of its strengths, like the virtualenv package, is that you can have completely different environments (installations) of python packages. This allows you to have a separate set of packages for different requirements, for example.
One drawback is that the different environments need to be activated so that the packages contained therein can be used.
For conda and your particular case, it seems that:
cd ~
source activate anaconda
Will activate the environment stored in $HOME/anaconda/.
Not that conda tells you where the environment is stored:
Fetching package metadata: ..
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/a/anaconda:
#
ipython-notebook 2.3.1 py27_0