数据挖掘前期搭建环境介绍

一,创建虚拟环境dm并启用该环境。
1、一开始先创建虚拟环境dm,指定它用解释器python3(可 which python3 来查看)

mkvirtualenv -p /usr/bin/python3 dm

创建dm 虚拟环境方法2:

virtualenv dm

补充:

hellopython@ubuntu:~$ which python3
/usr/bin/python3

找到dm所在的目录, 读取并执行dm/bin/activate脚本来启用该虚拟环境。

hellopython@ubuntu:~$ ls -a
Desktop           Pictures                         .virtualenvs
hellopython@ubuntu:~$ cd .virtualenvs/
hellopython@ubuntu:~/.virtualenvs$ ls
dm               postdeactivate    preactivate      prermvirtualenv
....
hellopython@ubuntu:~$ source dm/bin/activate
(dm) hellopython@ubuntu:~/.virtualenvs$

补充进入和退出虚拟环境:

python@ubuntu:~$ workon dm
(dm) python@ubuntu:~$ deactivate 
python@ubuntu:~$ 

二,在该环境中安装数据挖掘所需要的python库。
1、随便找个目录(比如:cd /tmp)创建文本,在里面放置一系列库名。

cd /tmp
vi requirements

2、在requirements中粘贴如下并输入 :wq 退出(TA-Lib==0.4.16 要在最后安装):

matplotlib==2.2.2
numpy==1.14.2
pandas==0.20.3
tables==3.4.2
jupyter==1.0.0

3、读取文本批量安装。

pip install -r requirements

如果想使用国内源可以(可提高网速):

pip install -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com -r requirements

建议用完就删除文本,有手尾。

rm -rf requirements 

安装ta-lib:

sudo wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz

解压进入目录

tar -zxvf ta-lib-0.4.0-src.tar.gz
cd ta-lib/

编译安装($ ./configure --prefix=/usr
用脚本/configure 执行–prefix命令,指定接下来安装的所有资源文件要放在/usr目录中。否则安装的内容会分散到其他目录。好处是只需要选中某个目录就能对该软件做卸载或移植,比四处找来卸载方便多了,不会有残留)

sudo ./configure --prefix=/usr  
sudo make
sudo make install

重新安装python的TA-Lib库

pip install TA-Lib

可能出现的问题:
Building wheel for TA-Lib (setup.py) … error / ERROR: Failed building wheel for TA-Lib
https://blog.csdn.net/weixin_43256057/article/details/103124908

easy_install: command not found 的解决办法

都是我的博客,按需查找即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章