2

Environment: I'm using conda 4.6.7 on a Mac with High Sierra.

I got some legacy Python code, and first of all I'd like to run it. Of course, since this is research code, I didn't expect to find "fancy stuff (!!)" such as a test suite, but I was hoping that at least a requirements.txt file would be provided. Pipe dream. After GREPping the list of imports across the various files composing the project, I came up with the following list of packages to be installed:

conda install os sys math time scipy numpy zipfile urllib.request shutil PIL skimage config itertools logging json re random collections matplotlib visualize glob random datetime tensorflow keras colorsys IPython

I put all of them in a single call to conda, because, according to

https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands

you should

Install all the programs that you want in this environment at the same time. Installing 1 program at a time can lead to dependency conflicts.

(btw, is there a way to include a line break in the command, or does it have to be that long?)

However, conda is giving me the error:

PackagesNotFoundError: The following packages are not available from current channels:

  - config
  - math
  - visualize
  - datetime
  - urllib.request
  - re
  - logging
  - json
  - os
  - glob
  - collections
  - sys
  - colorsys
  - itertools
  - random
  - zipfile
  - time
  - shutil
  - skimage

This seems weird to me, because at least some of them are very common. These are the packages in my conda environment:

# Name                    Version                   Build  Channel
ca-certificates           2019.1.23                     0
certifi                   2018.11.29               py36_0
libcxx                    4.0.1                hcfea43d_1
libcxxabi                 4.0.1                hcfea43d_1
libedit                   3.1.20181209         hb402a30_0
libffi                    3.2.1                h475c297_4
ncurses                   6.1                  h0a44026_1
openssl                   1.1.1b               h1de35cc_0
pip                       19.0.3                   py36_0
python                    3.6.8                haf84260_0
readline                  7.0                  h1de35cc_5
setuptools                40.8.0                   py36_0
sqlite                    3.26.0               ha441bb4_0
tk                        8.6.8                ha441bb4_0
wheel                     0.33.1                   py36_0
xz                        5.2.4                h1de35cc_4
zlib                      1.2.11               h1de35cc_3

How can I solve the above problem?

DeltaIV
  • 4,773
  • 12
  • 39
  • 86

2 Answers2

5

Most of those packages (e.g. math, random, itertools....) are part of the python standard library, so should be available with any standard installation of python (even if they don't show up in the output of conda list). Conda therefore does not install these separately or have them in its package lists.

Other issues with your attempt are with the names of packages. For instance, you are trying to install scikit-image, but using the shortform name skimage (which is used once it is installed for import, e.g. import skimage). If you use conda install scikit-image, conda will find it.

sacuL
  • 49,704
  • 8
  • 81
  • 106
  • Yeah, I just got the package names from GREPping though the files, thus they were all `import` statements. That's probably why this `scikit-image` package is named that way. Any other names which look weird to you? – DeltaIV Mar 05 '19 at 13:49
  • 2
    The only other one I don't know is `visualize`. That's maybe because it's just some obscure package I've never come across, or it's a part of the legacy code you're working with. Then, there's the `config` issue, which you can address by googling `python import config`. Other than that, I believe those are all in the standard library – sacuL Mar 05 '19 at 13:59
0

Try to do this via a shell script. Go to the folder where your requirements.txt is located then

while read requirement; do conda install --yes $requirement; done < requirements.txt

otherwise you dont necessarily have to use conda - just go to the environment

conda activate <environmentname>
pip install -r requirements.txt

for standard and some more ... packages

conda install anaconda
Vipluv
  • 884
  • 7
  • 23
  • There is no `requirements.txt` file. The authors didn't think of writing one. This is researchers' code, and not particularly well written. – DeltaIV Mar 05 '19 at 13:46
  • you can simply add all the names in a txt file that you have put in the question. Although, you can get rid of half of them by simply doing a conda install anaconda, this will install a whole bunch of packages and when you do import you will see which is missing – Vipluv Mar 05 '19 at 13:55