一文排除WINDOWS-PYTHON3.7环境安装WORD2VEC包的所有坑
之前介绍了很多R语言进行自然语言处理方面的东西,不过我们知道在自然语言处理上python平台还是当之无愧的王者,而我的笔记本又是windows的,平时通勤的过程中也想玩玩word2vec该如何做呢,今天我详细记录在windows平台下安装word2vec的过程。
首先配置pythson环境的方法我就不再赘述了,请参见https://beyondma.blog.csdn.net/article/details/88381705
一、word2vec安装时报“ [WinError 2] 系统找不到指定的文件”的问题解决
首先在尝试使用安装word2vec包时
[code]pip install word2vec
会报“Compilation command: gcc C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-psvn2ro\word2vec\word2vec\c\win32/word2vec.c -o Scripts\word2vec.exe -O2 -Wall -funroll-loops
error:”错误
这是因为windows环境下没有gcc命令所致的。
这里请参考https://blog.csdn.net/BEYONDMA/article/details/87902276中的第三项,安装Rtools我们知道 Rtools带有mingw环境,带有gcc和g++的编译器。
并添加环境变更D:\Rtools\mingw_32\bin到PATH环境变更中
配置完成后,在命令行中输入gcc会有如下返回,即代表安装成功。
gcc: fatal error: no input files
compilation terminated.
一、word2vec安装时报“ fatal error: win32-port.h”的问题解决
再重新尝试安装会发现报 “fatal error: win32-port.h: No such file or directory”我发现这个问题只能通过改变安装包还解决。
使用pip download word2vec命令去下载word2vec包,包应该就在python安装目录的根目录下,例如笔者的python.exe在D:\ProgramData\Anaconda3那么,word2vec包就在这个目录下,记得不要在这个目录解压缩,最好放在d:的根目录下解压,
然后到https://download.csdn.net/download/beyondma/下载win32-port.h
或者直接将下列代码段粘到win32-port.h中
[code]#if !defined WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include <Windows.h> #include <process.h> #include <assert.h> typedef struct { void *(*pthread_routine)(void *); void *pthread_arg; HANDLE handle; } pthread_t; static unsigned __stdcall win32_start_routine(void *arg) { pthread_t *p = (pthread_t *)arg; p->pthread_routine(p->pthread_arg); return 0; } static int pthread_create(pthread_t *id, void *attr, void *(*start_routine)(void *), void *arg) { assert(attr == 0); id->pthread_routine = start_routine; id->pthread_arg = arg; id->handle = (HANDLE)_beginthreadex(0, 0, win32_start_routine, (void *)id, 0, 0); if (id->handle != 0) return 0; return -1; } static int pthread_join(pthread_t thread, void **retval) { WaitForSingleObject(thread.handle, INFINITE); if (retval) { *retval = 0; } return 0; } static void pthread_exit(void *p) { _endthreadex(0); } static int posix_memalign(void **memptr, size_t alignment, size_t size) { assert(memptr); *memptr = _aligned_malloc(size, alignment); if (*memptr) { return 0; } else { return -1; } }
然后将win32-port.h文件拷到word2vec安装包的解压后的目录word2vec-版本号\word2vec\src\win32目录下
接下来在命令行进入word2vec安装包的解压后的目录
执行python setup.py install
好了word2vec就此安装完成。可以在python的IDE中import啦
- win10环境tensorflow安装(支持python3.7)
- Windows下Python虚拟环境安装及新建django项目
- windows环境python安装第三方库
- python MySQLdb在windows环境下的快速安装、问题解决方式
- windows环境下使用pip安装python的sklean包
- windows下安装python的C扩展编译环境(解决“Unable to find vcvarsall.bat”)
- Windows下Python环境、IDE、MySQL等安装教程
- python MySQLdb在windows环境下的快速安装、问题解决方式
- windows安装Python环境
- Python爬虫之Scrapy框架Windows环境安装
- python安装lxml,在windows环境下
- windows系统下eclipse安装指南 [含Python编程环境设置]
- windows环境下,python安装软件包 scipy 失败,报错:no lapack / blas resources found。
- Windows环境下安装Python2.x环境搭建
- [转载+补充][PY3]——环境配置(2)——windows下安装pycharm并连接Linux的python环境
- [转]windows下安装Python虚拟环境virtualenvwrapper-win
- Windows下python和django环境搭建之 PyCharm的安装及使用教程
- Python Windows环境安装配置,以及Eclipse+Pydev开发
- 【转】linux和windows下安装python集成开发环境及其python包
- windows下安装python科学计算环境,numpy scipy scikit ,matplotlib等