1

我正在尝试设置一个可以访问 png 模块的 Python 3 环境。当我列出已安装的软件包时,我得到了这个:

(Python3_Env) me@gimli:~$ conda list
# packages in environment at /home/me/anaconda2/envs/Python3_Env:
#
# Name                    Version                   Build  Channel
ca-certificates           2018.03.07                    0  
certifi                   2018.4.16                py37_0    anaconda
click                     6.7                      py37_0  
flask                     1.0.2                    py37_1  
itsdangerous              0.24                     py37_1  
jinja2                    2.10                     py37_0  
libedit                   3.1.20170329         h6b74fdf_2  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 7.2.0                hdf63c60_3  
libpng                    1.6.34               hb9fc6fc_0    anaconda
libstdcxx-ng              7.2.0                hdf63c60_3  
markupsafe                1.0              py37h14c3975_1  
ncurses                   6.1                  hf484d3e_0  
openssl                   1.0.2o               h20670df_0    anaconda
pip                       10.0.1                   py37_0  
png                       1.2.39                        0    sssdgc
pypng                     0.0.18                        0    eaton-lab
python                    3.7.0                hc3d631a_0  
readline                  7.0                  ha6073c6_4  
setuptools                39.2.0                   py37_0  
sqlite                    3.24.0               h84994c4_0  
tk                        8.6.7                hc745277_3  
werkzeug                  0.14.1                   py37_0  
wheel                     0.31.1                   py37_0  
xz                        5.2.4                h14c3975_4  
zlib                      1.2.11               ha838bed_2  

由于我有 png、pypng 和 libpng,我真的希望能够导入 png,但是当我尝试时,我得到了这个:

(Python3_Env) me@gimli:~$ python
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import png
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'png'
>>> 

还有什么我需要安装的,或者我需要了解安装到 conda 环境中的一些东西吗?

4

1 回答 1

0

conda包,sssdgc::png似乎是 libpng12:

$ conda create -yp ./p sssdgc::png
$ find  p
p
p/conda-meta
p/conda-meta/png-1.2.39-0.json
p/conda-meta/history
p/bin
p/bin/libpng-config
p/bin/libpng12-config
p/include
p/include/libpng12
p/include/libpng12/png.h
p/include/libpng12/pngconf.h
p/include/png.h
p/include/pngconf.h
p/lib
p/lib/pkgconfig
p/lib/pkgconfig/libpng.pc
p/lib/pkgconfig/libpng12.pc
p/lib/libpng.a
p/lib/libpng.la
p/lib/libpng.so
p/lib/libpng.so.3
p/lib/libpng.so.3.39.0
p/lib/libpng12.a
p/lib/libpng12.la
p/lib/libpng12.so
p/lib/libpng12.so.0
p/lib/libpng12.so.0.39.0
p/share
p/share/man
p/share/man/man3
p/share/man/man3/libpng.3
p/share/man/man3/libpngpf.3
p/share/man/man5
p/share/man/man5/png.5
$ rm -fr p

conda 包eaton-lab::pypng似乎是 pypng 的错误打包版本:

$ conda create -yp ./p eaton-lab::pypng
$ find p
p
p/conda-meta
p/conda-meta/pypng-0.0.18-0.json
p/conda-meta/history
$ rm -fr p

你真正想要的是pythonpypng

您可以 pip 安装它:

$ conda install pip
$ pip install pypng
$ python -c 'import png; print(png.__version__)'
  0.0.18

或者,从自动 anaconda 通道获取它(仅适用于 python 2):

$ conda install auto::pypng
$ python -c 'import png; print(png.__version__)'
  0.0.16
于 2018-08-01T19:27:12.017 回答