我正在使用 Anaconda,并且正在尝试导入 soundfile/pysoundfile。
我通过运行安装了该软件包
conda install -c conda-forge pysoundfile
Run Code Online (Sandbox Code Playgroud)
我认为它成功了,因为当我跑步时
conda list
Run Code Online (Sandbox Code Playgroud)
它显示:
pyopenssl 17.2.0 py36h5d7bf08_0
pyparsing 2.2.0 py36hb281f35_0
pyqt 5.6.0 py36he5c6137_6
pysocks 1.6.7 py36hfa33cec_1
pysoundfile 0.10.1 py_0 conda-forge
pytables 3.4.2 py36hfbd7ab0_2
pytest 3.2.1 py36h9963153_1
Run Code Online (Sandbox Code Playgroud)
为了确保我运行“正确的”python,我尝试运行
which python
Run Code Online (Sandbox Code Playgroud)
我得到
/anaconda3/bin/python
Run Code Online (Sandbox Code Playgroud)
但是当我打开 python 并尝试运行时
import soundfile
Run Code Online (Sandbox Code Playgroud)
我得到以下信息:
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/soundfile.py", line 142, in <module>
raise OSError('sndfile library not found')
OSError: sndfile library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call …Run Code Online (Sandbox Code Playgroud) 我想读取几个文件 json 文件并将它们写入带有 for 循环的数据帧。
review_categories = ["beauty", "pet"]
for i in review_categories:
filename = "D:\\Library\\reviews_{}.json".format(i)
output = pd.read_json(path_or_buf=filename, lines=True)
return output
Run Code Online (Sandbox Code Playgroud)
问题是我希望每个评论类别都有自己的变量,比如一个名为“beauty_reviews”的数据框,另一个名为“pet_reviews”的数据框,分别包含从 review_beauty.json 和 review_pet.json 读取的数据。