How can I install a conda environment when offline?

后端 未结 10 1645
-上瘾入骨i
-上瘾入骨i 2020-12-07 20:32

I would like to create a conda environment on a machine that has no network connection. What I\'ve done so far is:

On a machine that is connected to the internet:

相关标签:
10条回答
  • 2020-12-07 21:00

    You could try cloning root which is the base env.

    conda create -n yourenvname --clone root

    0 讨论(0)
  • 2020-12-07 21:02

    I'm not sure whether this contradicts the other answers or is the same but I followed the instructions in the conda documentation and set up a channel on the local file system.

    Then it's a simple matter of moving new package files to the local directory, running conda index on the channel sub-folder (which should have a name like linux-64).

    I also set the Anaconda config setting offline to True as described here but not sure if that was essential.

    Hope that helps.

    0 讨论(0)
  • 2020-12-07 21:09

    Have you tried without the --offline?

    conda create -n anaconda python=3.4 --channel PATHTO\Anaconda_py3
    

    This works for me if I am not connected to the Internet if I do have anaconda already on the machine but in another location. If you are connected to the Internet when you run this command you will probably get an error associated with not finding something on Binstar.

    0 讨论(0)
  • 2020-12-07 21:09

    Here's a solution that may help. It's not very pretty but it gets the job done. So i suppose you have a machine where you have a conda environment in which you've installed all the packages you need. I will refer to this as ENV1 You will have to go to this environment directory and locate it. It is usually found in \Anaconda3\envs. I suggest compressing the folder but you could just use it as is. Copy the desired environment folder into your offline machine's directory for anaconda environments. This first step should get your new environment to respond to commands like conda activate.

    You will notice though that software like spyder and jupyter don't work anymore (probably because of path differences). My solution to this was to clone the base environment in the offline machine into a new environment that i will refer to as ENV2. What you need to do then is copy the contents of ENV2 into those of ENV1 and replace files.

    This should overwrite the files related to spyder, jupyter.. and keep your imported packages intact.

    0 讨论(0)
  • 2020-12-07 21:10

    I found the simplest method to be as follows:

    1. Run 'conda create --name name package' with no special switches
    2. Copy the URL of the first package it tried (unsuccessfully) to download
    3. Use the URL on a connected machine to fetch the tar.bz2
    4. Copy the tar.bz2 to the offline machine's /home/user/anaconda3/pkgs
    5. Deploy the tar.bz2 in place
    6. Delete the now unneeded tar.bz2
    7. Repeat until the 'conda create' command succeeds
    0 讨论(0)
  • 2020-12-07 21:11

    Short answer: copy the whole environment from another machine with the same OS.

    Why

    Dependency. A package depends on other packages. When you install a package online, the package manager conda analyzes the package dependencies and install all the required packages for you.

    The dependency is especially heavy in anaconda. Cause anaconda is a meta package depends on another 160+ packages.

    Meta packages,are packages do not contain actual softwares and simply depend on other packages to be installed.

    It's totally absurd to download all these dependencies one by one and install them on the offline machine.

    Detail Solution

    1. Get conda installed on another machine with same OS. Install the packages you need in an isolated virtual environment.

      # create a env named "myvenv", name it whatever you want
      # and install the package into this env
      conda create -n myvenv --copy anaconda
      

      --copy is used to

      Install all packages using copies instead of hard- or soft-linking.

    2. Find where the environments are stored with

      conda info
      

      The 1st value of key "envs directories" is the location. Go there and package the whole sub-folder named "myvenv" (the env name in previous step) into an archive.

    3. Copy the archive to your offline machine. Check "envs directories" from conda info. And extract the environment from the archive into the env directory on the offline machine.

    4. Done.

    0 讨论(0)
提交回复
热议问题