The logical explanation of importing the third-party sound source library Acoular in Python and the download of Acoular

 [Declaration] Welcome to reprint, but please keep the original source of the article→_→

Qin study hard: http://www.cnblogs.com/Qinstudy/

Article source: http://www.cnblogs.com/Qinstudy/p/8987520.html

【text】 

Qin Xue is working hard as a blogger, hello! Now there is a project about sound source localization, which needs to use a third-party library of Python: the acoustic library (also called the acoustic package, the English name is Acoular). I will install the third-party package Acoular of Python by myself. The installation method doesn't always work! Qin Xue is a blogger, can you answer my doubts?

                                                                                                                                                                                                                                                       Acoular Acoustic Library Learner---Xiao Wang

Qin Xue's hard -working answer:

Xiao Wang, I have been in touch with the acoular acoustic library for a while. When I downloaded and installed the acoular package, I installed it and uninstalled it for a while. It took me a lot of effort to conquer it.

Since it is to download and install a certain package or software, the installation steps and methods will be different for different operating systems. So, Xiao Wang, let me first talk about the situation of my computer: win10 system; Python language version: Python3.6.4  

I downloaded and installed acoular in the following way:

First install Anaconda, then use the Anaconda Prompt command line to download the acoular package, and finally import the downloaded acoular package into Python .

 

Xiao Wang, don't rush to download the acoular library. Before you know how to download the acoular library, let me introduce three other softwares: Anaconda, Python, and PyCharm. If you understand the logical relationship between acoular and the three of them, you will feel that your problem is actually very easy to solve. Then I will walk you through the installation steps step by step. If you understand the following two parts, I believe you can find the reason why your installation failed.

Only after you know the reason for your failure will it be a matter of course when you install the sound source library acoular next time!

Xiao Wang, you may ask, if you just tell me the specific steps to install acoular, it will be OK, where is there so much nonsense? Haha, why do I want to talk about the logical relationship between Anaconda, acoular, Python, and PyCharm, because I often have this experience: when learning a thing or installing a software, if I don’t further understand and understand these steps, just Know to download and install mechanically, without exploring the why behind it. In a few days, I'll forget it myself, and then, next time I install it, I'll have to start all over again!

Therefore, Qin Xue’s hard practice often reminds himself that learning concepts is not only about learning the concepts themselves, but more importantly, understanding and understanding the origin of knowledge!

 

I will discuss it in two parts below. The first part is the foreshadowing of the second part, that is, the foundation. It is a piece of cake to understand the first part, the second part of acoular installation, and the third part of acoular import Python!

1. Basic concepts of Anaconda, acoular, Python and PyCharm and their logical relationship

2. Installation steps of acoular (valid for pro test)

Three.acoular import into Python

 

1. The logical relationship between Anaconda, acoular, Python and PyCharm

1. The relationship between sets and elements (Anaconda, acoular)

 1.1 Anaconda (an integrated development environment)

Anaconda is an integrated development environment. Anaconda comes with a large number of commonly used data science packages, including more than 150 scientific packages such as conda, python, and Numpy. Anaconda is developed on conda , Anaconda download file is relatively large (about 500 MB) , because it comes with the most commonly used data science packages in Python. If your project only needs some very few packages, and you also want to save computer space, then install a mini version of the integrated development environment, called miniconda, which only contains conda packages and python packages, the rest of the packages, if you own Which packages are needed, use the command line to download them!

The conda package is a package manager and environment manager . In sound source localization, you will use many third-party open source packages, such as Numpy packages, Scipy packages, etc., and conda (package manager) can help you install and manage these packages on your computer. You can Use conda packages to install , uninstall and update packages you need or don't need.

 1.2 acoular (a package (also called a library) for sound source localization)

acoular is a package created by the acoular development team. You can use the acoular package to do sound source localization related algorithms. For example, $   conda install –c acoular acoular  , after executing this statement, conda will help you install the acoular package on your computer. The acoualr package is a data package for sound source localization.

Summarize:

acoular is a package created by the acoular development team. You can use the acoular package to do sound source localization related algorithms. And Anaconda is an integrated development environment that includes the acoular package, which is just one of more than 150 packages in Anaconda . If you enter $    conda install -c acoular acoular  in the Anaconda Prompt command line , after the acoular package is successfully installed, Anaconda will contain the acoular package.

1.3 The logical relationship between Anaconda and acoular

Xiao Wang, you have also seen that 1.1 and 1.2 talked about the basic concepts of Anaconda and acoular. Let’s talk about the logical relationship between the two: In general, if you have installed the acoular package on your computer, and also installed Anaconda For the integrated development environment, there will be such a package in Anaconda, the name is acoular. like in mathematics. The relationship between sets and elements, Anaconda is equivalent to a set, when you add acoular (a package for sound source localization) elements into the Anaconda set, acoular becomes an element in the set.

 

2. Dependency tool of Python language---PyCharm

 2.1 Python (a programming language)

Xiao Wang, since you said that you are a learner of the acoular sound source library, I think you know a little bit about programming. Let me introduce you to the Python language by analogy. Python is a programming language. Like Java and C++, it is a high-level language. The installation of a programming language requires setting environment variables, that is, adding a PATH path. So you have to learn how to add the path (PATH). When installing the Python language, there is a dialog box: Add environment variables for python, and tick the box, so you don't have to manually add environment variables yourself!

If you forget to tick the box when installing, you need to manually add environment variables yourself. For example, the name of your Python installation directory is: D:\Python3.6.4, then you only need to add " ;D:\Python3.6.4 " at the end of the PATH path (this is in windows7 system); if in In the windows10 system, what you have to do is simpler, just create a new file in the PATH path, and then add "D:\Python3.6.4". What I need to remind you is that in win10, there is no semicolon to add the PATH path, which is a big difference between the win10 and win7 systems in setting the PATH path.

Xiao Wang, if you have not configured the PATH path, first patiently check whether the PATH path configuration is wrong, and carefully check it several times. If you still can't find the reason, you can ask your partner. Of course, the easier way is to uninstall Python and reinstall it. At this time, you have to remember: if there is a dialog box, add environment variables for python and tick it, so you don't need to manually add environment variables yourself.

 2.2 PyCharm (an integrated development environment)

Xiao Wang, after downloading, installing and configuring the PATH path, if you want to write Python code well, you need to install a very useful integrated development environment--PyCharm. With PyCharm, you don't have to type, compile, and run code on the command line. You only need to write code in the PyCharm IDE, then click the Run button, and PyCharm will compile and run the code for you. All in all, use the IDE to compile and run the code yourself on the command line, so that you can save a lot of time and use the saved time to learn the things you are interested in!

So, what is PyCharm? PyCharm is an integrated development environment. PyCharm is a Python IDE (called Python integrated development environment) created by JetBrains. PyCharm has the functions of general integrated development environments, such as debugging, syntax highlighting, Project management, code jumping turn, smart prompts, etc.

 

 

3.Anaconda、acoularPython、Pycharm四者的逻辑关系

秦学苦练的逻辑分析:小王同学,你看了Anaconda、acoular、Python、Pycharm四者的基本概念后,我向你提个问题,问题如下:

如果我现在的目的,是在PyCharm集成开发环境中去使用Anaconda集成开发环境中的acoular包,我该怎么做呢?下面是逻辑分析:

因为我要用到acoular这个包,如果使用Project Interpreter(项目编译器)中的D:\Python3.6.4\python.exe路径,是不可能导入出acoular包,原因是acoular包位于Anaconda集成开发环境中,所以当Project Interpreter(项目解释器)中的路径是:D:\Python3.6.4\python.exe 时,PyCharm会报错,报错如下:找不到“acoular”。

正确的做法是将Project Interpreter(项目编译器)中的路径改为:D:Anaconda\python.exe ,这样修改后,编译器就会沿着D:Anaconda\python.exe这条路径去寻找Anaconda中的acoular包,最后找到了acoular包。于是在PyCharm集成开发环境中,编译通过,即acoular导入成功!

 

 二. acoular的下载步骤(亲测有效)

小王同学,如果你想要下载并使用acoular声学库,你首先需要下载下面这些库:

NumPy,SciPy,Traits,scikit-learn (aka sklearn),pytables (aka tables),numba,PyQt,traitsui,libpython (only for Windows),configparser (only for Python 2.7),
six (only for Python 3)

你可能会问:为什么需要下载上面这些库呢?其实,当你自己去使用acoular声学库后,答案是挺简单的。因为acoular声学库里面的许多算法(比如绘制图形的plot函数、array数组)都依赖上面这些库。所以,小王,如果你手动去删除某个库,程序是会报错的,报错原因是:找不到你删除的那个库。

小王,如果你一个个去下载上面这些库,是很繁琐、浪费时间的,所以我推荐你使用另一种简便的方法:第一步先安装Anaconda,然后使用Anaconda Prompt命令行去下载acoular包,最后将下载的acoular包导入到Python

总的来说,下载并使用acoular可以分成下面几个步骤:

1.下载并安装Anaconda(注意:Anaconda中路径PATH的配置);

2.使用Anaconda Prompt命令行去下载acoular包;

3.将acoular声学包导入PyCharm集成开发环境中。

 

下面秦学苦练博主按步骤一步一步往下执行:

1.下载并安装Anaconda(Anaconda中路径PATH的配置)

小王同学,Anaconda的下载和安装网上有许多教程,从你写的信中,我相信你具备下载并安装Anaconda的实力。但我需要提醒你:Anaconda的安装过程需要配置路径PATH,如果没有配置路径PATH,那么你在Anaconda Prompt命令行中输入:conda      ,会报错,报错内容如下:‘conda’不是内部、外部命令,也不是可运行的程序或批处理文件。编译器为什么会报错呢,原因是小王你没有配置路径PATH。解决办法如下:

Anaconda安装时,有个对话框中:为Anaconda添加环境变量,打上对勾,就不用自己手动去添加环境变量了!

如果你安装的时候忘了打上对勾,需要自己手动去添加环境变量。比如,小王同学,你的Anaconda的安装目录名称为:D:\Anaconda。

在windows10系统中,你只需要在PATH路径中新建一个文件,然后添加“D:\Anaconda\Scripts”即可。需要提醒你的是,win10中,添加PATH路径没有分号,这是win10和win7系统设置PATH路径的一个很大的区别。

小王,要是你配置好PATH路径后,再次在Anaconda Prompt命令行中输入:conda      ,如果能运行,则环境配置这一关,你顺利通过了!如果,仍然报错:‘conda’不是内部、外部命令,也不是可运行的程序或批处理文件。首先,你要去耐心地去检查PATH路径配置是否出错了,细心地去检查几次。若你还是找不到原因的话,可以问问身边的伙伴。当然,更简便的办法,是卸载Anaconda后(卸载Anaconda的方法:双击uninstall图标,等待程序运行就OK了),然后重新安装,这时你就要记住:有对话框中,为Anaconda添加环境变量,打上对勾,就不需要自己手动去添加环境变量了。

 

2.使用Anaconda Prompt命令行去下载acoular包

小王同学,既然你现在看到了第二部分,第一部分的内容、注意事项(为Anaconda配置环境变量)你一定都弄懂了。下面秦学苦练用图片和文字交错的方式,说明acoular下载过程。

第一步:在Anaconda Prompt命令行中输入如下代码    :

 conda install -c acoular acoular 

小王,你可能要问这是什么意思?其实,你认真的读一读,看懂代码中的英文单词,大致能猜出这条语句的作用。我想你已经猜出来了,上面这行语句作用是:用conda(一个包管理器和环境管理器,用conda包去安装、卸载和更新
自己需要或者不需要的包)去下载、安装acoular声学库。

小王,你输入这行代码运行后,Anaconda Prompt命令行界面如下:

 

 第二步:Anaconda Prompt命令行中出现:Proceed([y]/n)?

这条语句意思是编译器在询问:是否需要覆盖旧版本?如果覆盖旧版本,输入:  ;如果不覆盖旧版本,输入: n 。这里你选择覆盖旧版本,所以键盘输入:y  。

小王,如果你选择覆盖旧版本之后,Anaconda Prompt命令行中会下载相应的文件、数据包,Anaconda Prompt命令行中界面如下:

 

第三步:输入acoular库提供的一个例子,验证acoular是否安装成功

小王同学,你耐心地等待第二步完成后,在Anaconda Prompt命令行中输入如下代码:

acoular_demo

上面这行代码是显示acoular库中的一个例子,等待几秒钟后,电脑上会出现两张图片,一张是含有3个声源的声源图,另一张是64个麦克风的图片。Anaconda Prompt命令行中界面如下:

 小王,当你执行完上面三个小步骤后,acoular的下载、安装就成功了。接下来,秦学苦练会告诉你,如何将acoular导入Python中?

 

三. Acoular导入Python中

小王,如果你想要在Python中使用acoular声学库,你需要将PyCharm集成开发环境中的Project Interpreter(项目编译器)的路径进行修改。因为当Project Interpreter(项目解释器)中的路径是:D:\Python3.6.4\python.exe 时,PyCharm会报错,报错如下:找不到“acoular”。

还记得一.3 中,Anaconda、acoular、Python、Pycharm四者的逻辑关系中,秦学苦练的逻辑分析吗?

在PyCharm集成开发环境中去使用Anaconda集成开发环境中的acoular包,该怎么做呢?下面是逻辑分析:

因为小王你要用到acoular这个包,如果使用Project Interpreter(项目编译器)中的D:\Python3.6.4\python.exe路径,是不可能导入出acoular包,原因是acoular包位于Anaconda集成开发环境中,所以当Project Interpreter(项目解释器)中的路径是:D:\Python3.6.4\python.exe 时,PyCharm会报错,报错如下:找不到“acoular”。

正确的做法是将Project Interpreter(项目编译器)中的路径改为:D:Anaconda\python.exe ,这样修改后,编译器就会沿着D:Anaconda\python.exe这条路径去寻找Anaconda中的acoular包,最后找到了acoular包。于是在PyCharm集成开发环境中,编译通过,即acoular导入成功!

双击打开PyCharm后,点击File/Setting/Project:/Project Interpreter,然后将Project Interpreter的路径修改为:D:Anaconda\python.exe   。具体操作如下图:

小王啊,你走完这些步骤后,acoular声学库的下载安装以及导入就成功了!你可以用acoular库去实现声源定位的算法,好好地去完成你的项目吧,祝你好运!

 

 四.方法论

Xiao Wang, I am very glad that you can raise the question of "how to import the third-party acoustic library Acoular in Python". This interesting question prompted me to think about the logical relationship among Anaconda, acoular, Python, and Pycharm . I have told you the knowledge of downloading, installing and importing the Acoular library. I think Qin Xue's hard work has deepened the logical explanation of "Importing the acoustic library Acoular in Python"! This makes bloggers understand once again that learning concepts is not only about learning the concepts themselves, but more importantly, understanding and understanding the origin of knowledge! 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325284201&siteId=291194637