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
Related
Here's an excerpt from my environment.yml:
name: my-project
channels:
- pytorch-nightly
- defaults
dependencies:
- pytorch=1.13.0.*
- pip:
- https://github.com/explosion/spacy-models/releases/download/nb_core_news_md-3.3.0/nb_core_news_md-3.3.0-py3-none-any.whl
prefix: ~/opt/miniconda3/envs/my-project
When I create my environment (conda env create -f environment.yml) and re-export it to environment.yml (conda env export > environment.yml), the file gets changed:
name: my-project
channels:
- pytorch-nightly
- defaults
dependencies:
- pytorch=1.13.0.dev20220614=py3.9_0
- pip:
- nb-core-news-md==3.3.0
prefix: ~/opt/miniconda3/envs/my-project
Then, when I re-create my environment the next day, Conda complains that pytorch=1.13.0.dev20220614=py3.9_0 does not exist because it was replaced by a new PyTorch Preview (Nightly) build. dev20220614=py3.9_0 is no longer available.
Conda also complains that nb-core-news-md==3.3.0 does not exist. It was installed via a URL directly to the whl. That URL was removed from the environment.yml.
How can I prevent conda env export from changing these two dependencies? I still want Conda to lock down the specifics for all other dependencies, just not for these two.
I get why PyTorch is deleting daily builds, but it's kind of disruptive for the workflow you have. What you're asking for cannot be expressed with Conda CLI commands. Instead, consider exporting the regular YAML, but then run some sed commands to replace the particular requirements prior to recreating the environment.
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.
Hopefully someone can point me in the right direction here.
I'm using the latest release of Anaconda (Python 2.7). I would like to use it with OpenCV with the tracking features. I've tried various versions of the cv2.pyd file including 3.0, 3.1, 3.2, 3.3 and 3.4. However, the examples I've found use one of the following commands which are not found in the module.
tracker = cv2.Tracker_create(tracker_type)
or
tracker = cv2.TrackerKCF_create()
The usage of either of these depends which OpenCV version is being used. However, neither of them work, both with the following error.
'module' object has no attribute 'Tracker_create / or TrackerKCF_create'
All of the other features in OpenCV seem to work fine.
Is the cv2.pyd file I'm extracting from the Windows OpenCV install limited to certain features?
If I use the following in the Anaconda Prompt
conda install -c menpo opencv3
it installs the tracking features I need. However, it installs v3.1 of OpenCV which is known to have bugs with the tracking features. Ideally I wan't v3.4 of OpenCV.
Any help would be appreciated.
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/opencv & python 3.6
name: opencv-env # any name for the environment
channels:
- conda-forge
dependencies: # everything under this, installed by conda
- python=3.6
- opencv=3.4
- pip: # everything under this, installed by pip
- future
environment.yml using pip/opencv-python & python 3.6
name: opencv-env # any name for the environment
channels:
- defaults
dependencies: # everything under this, installed by conda
- python=3.6
- pip: # everything under this, installed by pip
- future
- opencv-python>=3.4
How to install the environment?
conda create --force -f environment.yml
How to activate the environment?
source activate opencv-env
Once you've activated the environment, you can check the version of opencv.
I am trying to install a new conda environment that will be totally separate from my other environments, so I run:
conda create --name foot35 python=3.5
Anaconda then asks for my approval to install these NEW packages:
asn1crypto: 0.22.0-py35he3634b9_1
ca-certificates: 2017.08.26-h94faf87_0
cachecontrol: 0.12.3-py35h3f82863_0
certifi: 2017.7.27.1-py35hbab57cd_0
cffi: 1.10.0-py35h4132a7f_1
chardet: 3.0.4-py35h177e1b7_1
colorama: 0.3.9-py35h32a752f_0
cryptography: 2.0.3-py35h67a4558_1
distlib: 0.2.5-py35h12c42d7_0
html5lib: 0.999999999-py35h79d4e7f_0
idna: 2.6-py35h8dcb9ae_1
lockfile: 0.12.2-py35h667c6d9_0
msgpack-python: 0.4.8-py35hdef45cb_0
openssl: 1.0.2l-vc14hcac20b0_2 [vc14]
packaging: 16.8-py35h5fb721f_1
pip: 9.0.1-py35h69293b5_3
progress: 1.3-py35ha84af61_0
pycparser: 2.18-py35h15a15da_1
pyopenssl: 17.2.0-py35hea705d1_0
pyparsing: 2.2.0-py35hcabcaab_1
pysocks: 1.6.7-py35hb30ac0d_1
python: 3.5.4-hedc2606_15
requests: 2.18.4-py35h54a615f_1
setuptools: 36.5.0-py35h21a22e4_0
six: 1.10.0-py35h06cf344_1
urllib3: 1.22-py35h8cc84eb_0
vc: 14-h2379b0c_1
vs2015_runtime: 14.0.25123-hd4c4e62_1
webencodings: 0.5.1-py35h5d527fb_1
wheel: 0.29.0-py35hdbcb6e6_1
win_inet_pton: 1.0.1-py35hbef1270_1
wincertstore: 0.2-py35hfebbdb8_0
I don't know why it suggests these specific ones. I looked up lockfile and its website says:
Note: This package is deprecated.
Here is a screenshot of my command prompt as additional information.
I am trying to do a clean install that is unrelated/independent to the root environment.
Why is conda trying to install these things and how do I fix it?
conda create will "Create a new conda environment from a list of specified packages." ( https://conda.io/docs/commands/conda-create.html )
What list??!? The .condarc file is the conda configuration file.
https://conda.io/docs/user-guide/configuration/use-condarc.html#overview
The .condarc file can change many parameters, including:
Where conda looks for packages.
If and how conda uses a proxy server.
Where conda lists known environments.
Whether to update the bash prompt with the current activated environment name.
Whether user-built packages should be uploaded to Anaconda.org.
**Default packages or features to include in new environments.**
Additionally, if you ever typed conda config, even accidentally...
The .condarc file is not included by default, but it is automatically created in your home directory the first time you run the conda config command.
A .condarc file may also be located in the root environment, in which case it overrides any in the home directory.
If you would like a single clean env then Boshika's recommendation of --no-default-packages flag for an instance though, you can check and modify the default packages for all further envs. ( https://conda.io/docs/user-guide/configuration/use-condarc.html#always-add-packages-by-default-create-default-packages )
Always add packages by default (create_default_packages)
When creating new environments, add the specified packages by default. The default packages are installed in every environment you create. You can override this option at the command prompt with the --no-default-packages flag. The default is to not include any packages.
EXAMPLE:
create_default_packages:
- pip
- ipython
- scipy=0.15.0
Lockfile may be there due to legacy requirements across all operating systems. Hopefully, you have the tools to remove it if you choose.
To avoid conda from installing all default packages you can try this
conda create --name foot35 --no-deps python=3.5
please don't loose the hope it's very weird for me also.
What you have to do just follow the steps: -
1.Download the anaconda for you system from it's official site and Install it : https://repo.continuum.io
After the Installation process, you can select your own package from there and please don't need to download anything from anywhere, it's full of packages over the internet.
3.If you want to work on python download Syder IDE its very useful for the Machine learning library.
Don't create other environment instead of root by defaults otherwise you have to duplicate all the file again, if there is any error while installing in root so close the window and again run as administration and after that its works fine.
Cause all the file in your root environment so you don't worry about the path in future and you can install and uninstall the packages : like - numpy , pandas, tensorflow and its gpu , scikit-learn etc from there eaisly.
Thank you
These packages are generally useful if you wish to pip install ... anything. Without many of them doing a pip install requests could result in errors such as these (and more)
No Module named Setuptools
pip: command not found
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
The issue that the conda create ... exposes is that the packages it wants to pull down are variable (based on when you create the environment). If you wish to maintain the same environment for you and for those who may collaborate with you, then freezing or pinning conda create's default installed package may be necessary.
One way of doing this is creating your environment with conda env create using a conda environment YAML file such as this example:
dependencies:
- ca-certificates=2018.03.07
- certifi=2018.4.16
- libedit=3.1.20170329
- libffi=3.2.1
- ncurses=6.1
- openssl=1.0.2o
- pip=10.0.1
- python=3.6.6
- readline=7.0
- setuptools=40.0.0
- sqlite=3.24.0
- tk=8.6.7
- wheel=0.31.1
- xz=5.2.4
- zlib=1.2.11
conda env create -n <NAME_OF_ENVIRONMENT> -f <PATH_TO_CONDA_REQUIREMENTS_FILE>
(note it's conda env create not conda create)
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