当前位置:首页>开发>正文

pycharm怎么安装jieba python怎么加载jieba模块

2023-04-19 02:59:58 互联网 未知 开发

 pycharm怎么安装jieba python怎么加载jieba模块

pycharm怎么安装jieba

中文分词库FNLP与jieba的安装与使用_职业教育_百度经验
https://jingyan.baidu.com/album/76a7e40911fe99fc3b6e15d2.html?picindex=1

python怎么加载jieba模块

首先安装jieba模块,pip install jieba
然后在程序里引用,import jieba
import jieba

seg_list = jieba.cut("我来到北京清华大学,我来到北京清华大学", cut_all=True)
print("Full Mode: "   "/ ".join(seg_list))  # 全模式
# 输出: Full Mode: 我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学/ / / 我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学

python 怎么安装pillow

1. 安装pip

[plain] view plain copy
sudo easy_install pip

pip 安装成功就可以直接安装pil或者pillow

2. 通过命令pip install pil

[plain] view plain copy
pip install Pil
Downloading/unpacking Pil
Could not find any downloads that satisfy the requirement Pil
Some externally hosted files were ignored (use --allow-external Pil to allow).
Cleaning up...
No distributions at all found for Pil
Storing debug log for failure in /Users/macbook/Library/Logs/pip.log

3. 所以就安装pillow

[plain] view plain copy
pip install --use-wheel Pillow
Downloading/unpacking Pillow
Downloading Pillow-2.4.0.zip (6.5MB): 5.0MB downloaded
Cleaning up...

弄了会别的回来发现还没有下载完,这叫一个慢呀,于是放弃
4. 通过Git下载源码地址https://github.com/python-imaging/Pillow

[plain] view plain copy
git clone https://github.com/python-imaging/Pillow.git

然后开始编译安装
4.1

[plain] view plain copy
python setup.py build_ext -i

编译完之后会提示运行测试例子,并且发现JPEG support not available

[plain] view plain copy
--------------------------------------------------------------------
version Pillow 2.4.0
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

To check the build, run the selftest.py script.

4.2 因为JPEG support not available,运行python selftest.py报告错误

[plain] view plain copy
1 tests of 57 failed.

于是只好卸载pillow

可以通过pip命令来卸载

[plain] view plain copy
pip uninstall pillow
sudo pip uninstall pillow
Password:
Uninstalling Pillow:
/Library/Python/2.7/site-packages/Pillow-2.4.0-py2.7-macosx-10.9-intel.egg
/usr/local/bin/pilconvert.py
/usr/local/bin/pildriver.py
/usr/local/bin/pilfile.py
/usr/local/bin/pilfont.py
/usr/local/bin/pilprint.py
Proceed (y/n)? y
Successfully uninstalled Pillow

成功之后需要安装libjpeg的支持

[plain] view plain copy
brew install libjpeg

安装成功之后重新编译pillow

[plain] view plain copy
--------------------------------------------------------------------
version Pillow 2.4.0
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------

[plain] view plain copy
python selftest.py

[plain] view plain copy
--------------------------------------------------------------------
Pillow 2.4.0 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL
Binary modules loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- JPEG support ok
*** JPEG 2000 support not installed
--- ZLIB (PNG/ZIP) support ok
*** LIBTIFF support not installed
--- FREETYPE2 support ok
*** LITTLECMS2 support not installed
*** WEBP support not installed
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.

最后执行安装

[plain] view plain copy
sudo python setup.py install

python怎么安装redis

redis python-redis 安装详细步骤
安装redis
把redis安装到 /opt/redis-2.8目录中

tar -zxfx redis-2.8.1.tar.gz
cd redis-2.8.make && make PREFIX=/opt/redis-2.8 install
cp redis.conf /opt/redis-2.8/
只是把redis当做队列用,不需要存储,所以编辑 /opt/redis-2.8/redis.conf
设置 daemonize yes
把3条 save .. 都注释掉,这样就关闭了硬盘存储
启动redis 非常简单: /opt/redis-2.8/bin/redis-server /opt/redis-2.8/redis.conf
$REIDS_INSTALL_DIR/utils/redis_init_script 这个脚本稍做修改就可以放到/etc/init.d 作为redis启动脚本用
安装python
CentOS 自带的python2.4,太旧了,升级到2.
tar -zvxf Python-2.7.6.tgz
cd Python-2.7../configure
make && make install
替换系统默认的python: sudo ln -s /usr/local/bin/python2.7 /usr/bin/python
安装python的redis模块
wget --no-check-certificate 2.8.0.tar.gz
tar -zvxf redis-2.8.0.tar.gz
mv redis-2.8.0 python-redis-2.8.0
cd python-redis-2.8.0
python setup.py install
部署成功

最新文章