我使用命令“ conda install -c conda-forge sox ”安装了sox,并使用了“ conda install -c davidbgonzalez pysox ”安装了pysox。但是,当我尝试导入sox时,提示“没有名为sox的模块”。如何解决这个问题?
答案 0 :(得分:0)
如果您查看https://pythonhosted.org/pysox/intro.html#simple-examples上的示例,则需要导入pysox
,而不是sox
:
$ python
Python 2.7.15 |Anaconda, Inc.| (default, Oct 23 2018, 18:31:10)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pysox # or the one below
>>> from pysox import sox
此外,首次尝试此操作时,您可能会看到错误:
>>> import pysox
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/p/lib/python2.7/site-packages/pysox/__init__.py", line 60, in <module>
from pysox.sox import CSoxStream, CEffect, CEffectsChain, CPysoxPipeStream
ImportError: libsox.so.2: cannot open shared object file: No such file or directory
那是因为conda-forge提供了sox v14.4.2(它提供了libsox.so.3),而davidbgonzalez提供的pysox是针对较旧的版本构建的。
查看https://abi-laboratory.pro/index.php?view=timeline&l=sox,并希望此pysox版本不使用任何已删除的符号,然后可以通过创建符号链接并用手指交叉来解决此问题:
$ ln -s $CONDA_PREFIX/lib/libsox.so.{3,2}
$ ls -l $CONDA_PREFIX/lib/libsox.so.2
lrwxrwxrwx. 1 nwani nwani 22 Nov 10 23:54 /tmp/p/lib/libsox.so.2 -> /tmp/p/lib/libsox.so.3