Apparently conda cannot find some very common packages: what am I doing wrong?

余生长醉 提交于 2019-12-07 21:01:42

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/55003896/apparently-conda-cannot-find-some-very-common-packages-what-am-i-doing-wrong

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!