win64下Python中NLTK的安装方法

Python已经更新至3.6版本,但是2.7.3的版本也足以使用。但是win64版本之下却没有Python中NLTK的安装包,网络之上的NLTK安装方法也有很多,本人也是演过很多种,很明显,都不成功,于是写下这个

一.安装Python
1.首先Python官网下载python-2.7.3.amd64.msi这个文件。安装之后就要使用了。
会有如下问题

按照网上的方法,你需要设置路径。方法如下:右键:我的电脑–>属性–>高级系统设置–>环境变量,
2.Python安装在D:\Program Files\Python

设置环境变量:()

Path 中增加 D:\Program Files\Python;D:\Program Files\Python\Scripts;

Pathext 中增加 .PY;.PYM;

这时在cmd中测试 python 安装成功(引用自http://www.xuebuyuan.com/1490918.html 博文)

当然,这个方法对于我来说是不成功的

方法二,
C:\Users\yyiyiyi>set PATH=%PATH%;D:\Python27;;
C:\Users\yyiyiyi>这部分在cmd本来就有的,只需要后面的,不同目录分号隔开,后面安装pip的时候也会遇到
这个时候已经成功

第一步已经完成了(可以参考http://blog.sina.com.cn/s/blog_6d65717d010176er.html)
二. Win10 64位 python easy_install 的安装

32位有直接安装包,但是64位的需要ez_setup.py安装,下载ez_setup.py后,进入文件所在目录,>python ez_setup.py 顺利的话就安装好了,可以在D:\Program
Files\Python\Scripts 下看见easy_install.exe 文件了,这时从cmd下进入Scripts目录,就可以运行easy_install XXX 了。如果想设置环境变量也可以,在Path中添加即可,但如果用的不多 ,没必要吧。

参考 http://www.cnblogs.com/zhuyp1015/archive/2012/07/17/2596495.html (这个里面给出的ez_setup是不全的。。。)
给出一个全的代码(有点长,复制的时候注意)

#!/usr/bin/env python"""
Setuptools bootstrapping installer.Maintained at https://github.com/pypa/setuptools/tree/bootstrap.Run this script to install or upgrade setuptools.This method is DEPRECATED. Check https://github.com/pypa/setuptools/issues/581 for more details.
"""import os
import shutil
import sys
import tempfile
import zipfile
import optparse
import subprocess
import platform
import textwrap
import contextlibfrom distutils import logtry:from urllib.request import urlopen
except ImportError:from urllib2 import urlopentry:from site import USER_SITE
except ImportError:USER_SITE = None# 33.1.1 is the last version that supports setuptools self upgrade/installation.
DEFAULT_VERSION = "33.1.1"
DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/"
DEFAULT_SAVE_DIR = os.curdir
DEFAULT_DEPRECATION_MESSAGE = "ez_setup.py is deprecated and when using it setuptools will be pinned to {0} since it's the last version that supports setuptools self upgrade/installation, check https://github.com/pypa/setuptools/issues/581 for more info; use pip to install setuptools"MEANINGFUL_INVALID_ZIP_ERR_MSG = 'Maybe {0} is corrupted, delete it and try again.'log.warn(DEFAULT_DEPRECATION_MESSAGE.format(DEFAULT_VERSION))def _python_cmd(*args):"""Execute a command.Return True if the command succeeded."""args = (sys.executable,) + argsreturn subprocess.call(args) == 0def _install(archive_filename, install_args=()):"""Install Setuptools."""with archive_context(archive_filename):# installinglog.warn('Installing Setuptools')if not _python_cmd('setup.py', 'install', *install_args):log.warn('Something went wrong during the installation.')log.warn('See the error message above.')# exitcode will be 2return 2def _build_egg(egg, archive_filename, to_dir):"""Build Setuptools egg."""with archive_context(archive_filename):# building an egglog.warn('Building a Setuptools egg in %s', to_dir)_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)# returning the resultlog.warn(egg)if not os.path.exists(egg):raise IOError('Could not build the egg.')class ContextualZipFile(zipfile.ZipFile):"""Supplement ZipFile class to support context manager for Python 2.6."""def __enter__(self):return selfdef __exit__(self, type, value, traceback):self.close()def __new__(cls, *args, **kwargs):"""Construct a ZipFile or ContextualZipFile as appropriate."""if hasattr(zipfile.ZipFile, '__exit__'):return zipfile.ZipFile(*args, **kwargs)return super(ContextualZipFile, cls).__new__(cls)@contextlib.contextmanager
def archive_context(filename):"""Unzip filename to a temporary directory, set to the cwd.The unzipped target is cleaned up after."""tmpdir = tempfile.mkdtemp()log.warn('Extracting in %s', tmpdir)old_wd = os.getcwd()try:os.chdir(tmpdir)try:with ContextualZipFile(filename) as archive:archive.extractall()except zipfile.BadZipfile as err:if not err.args:err.args = ('', )err.args = err.args + (MEANINGFUL_INVALID_ZIP_ERR_MSG.format(filename),)raise# going in the directorysubdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])os.chdir(subdir)log.warn('Now working in %s', subdir)yieldfinally:os.chdir(old_wd)shutil.rmtree(tmpdir)def _do_download(version, download_base, to_dir, download_delay):"""Download Setuptools."""py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)tp = 'setuptools-{version}-{py_desig}.egg'egg = os.path.join(to_dir, tp.format(**locals()))if not os.path.exists(egg):archive = download_setuptools(version, download_base,to_dir, download_delay)_build_egg(egg, archive, to_dir)sys.path.insert(0, egg)# Remove previously-imported pkg_resources if present (see# https://bitbucket.org/pypa/setuptools/pull-request/7/ for details).if 'pkg_resources' in sys.modules:_unload_pkg_resources()import setuptoolssetuptools.bootstrap_install_from = eggdef use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,to_dir=DEFAULT_SAVE_DIR, download_delay=15):"""Ensure that a setuptools version is installed.Return None. Raise SystemExit if the requested versionor later cannot be installed."""to_dir = os.path.abspath(to_dir)# prior to importing, capture the module state for# representative modules.rep_modules = 'pkg_resources', 'setuptools'imported = set(sys.modules).intersection(rep_modules)try:import pkg_resourcespkg_resources.require("setuptools>=" + version)# a suitable version is already installedreturnexcept ImportError:# pkg_resources not available; setuptools is not installed; downloadpassexcept pkg_resources.DistributionNotFound:# no version of setuptools was found; allow downloadpassexcept pkg_resources.VersionConflict as VC_err:if imported:_conflict_bail(VC_err, version)# otherwise, unload pkg_resources to allow the downloaded version to#  take precedence.del pkg_resources_unload_pkg_resources()return _do_download(version, download_base, to_dir, download_delay)def _conflict_bail(VC_err, version):"""Setuptools was imported prior to invocation, so it isunsafe to unload it. Bail out."""conflict_tmpl = textwrap.dedent("""The required version of setuptools (>={version}) is not available,and can't be installed while this script is running. Pleaseinstall a more recent version first, using'easy_install -U setuptools'.(Currently using {VC_err.args[0]!r})""")msg = conflict_tmpl.format(**locals())sys.stderr.write(msg)sys.exit(2)def _unload_pkg_resources():sys.meta_path = [importerfor importer in sys.meta_pathif importer.__class__.__module__ != 'pkg_resources.extern']del_modules = [name for name in sys.modulesif name.startswith('pkg_resources')]for mod_name in del_modules:del sys.modules[mod_name]def _clean_check(cmd, target):"""Run the command to download target.If the command fails, clean up before re-raising the error."""try:subprocess.check_call(cmd)except subprocess.CalledProcessError:if os.access(target, os.F_OK):os.unlink(target)raisedef download_file_powershell(url, target):"""Download the file at url to target using Powershell.Powershell will validate trust.Raise an exception if the command cannot complete."""target = os.path.abspath(target)ps_cmd = ("[System.Net.WebRequest]::DefaultWebProxy.Credentials = ""[System.Net.CredentialCache]::DefaultCredentials; "'(new-object System.Net.WebClient).DownloadFile("%(url)s", "%(target)s")'% locals())cmd = ['powershell','-Command',ps_cmd,]_clean_check(cmd, target)def has_powershell():"""Determine if Powershell is available."""if platform.system() != 'Windows':return Falsecmd = ['powershell', '-Command', 'echo test']with open(os.path.devnull, 'wb') as devnull:try:subprocess.check_call(cmd, stdout=devnull, stderr=devnull)except Exception:return Falsereturn True
download_file_powershell.viable = has_powershelldef download_file_curl(url, target):cmd = ['curl', url, '--location', '--silent', '--output', target]_clean_check(cmd, target)def has_curl():cmd = ['curl', '--version']with open(os.path.devnull, 'wb') as devnull:try:subprocess.check_call(cmd, stdout=devnull, stderr=devnull)except Exception:return Falsereturn True
download_file_curl.viable = has_curldef download_file_wget(url, target):cmd = ['wget', url, '--quiet', '--output-document', target]_clean_check(cmd, target)def has_wget():cmd = ['wget', '--version']with open(os.path.devnull, 'wb') as devnull:try:subprocess.check_call(cmd, stdout=devnull, stderr=devnull)except Exception:return Falsereturn True
download_file_wget.viable = has_wgetdef download_file_insecure(url, target):"""Use Python to download the file, without connection authentication."""src = urlopen(url)try:# Read all the data in one block.data = src.read()finally:src.close()# Write all the data in one block to avoid creating a partial file.with open(target, "wb") as dst:dst.write(data)
download_file_insecure.viable = lambda: Truedef get_best_downloader():downloaders = (download_file_powershell,download_file_curl,download_file_wget,download_file_insecure,)viable_downloaders = (dl for dl in downloaders if dl.viable())return next(viable_downloaders, None)def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,to_dir=DEFAULT_SAVE_DIR, delay=15,downloader_factory=get_best_downloader):"""Download setuptools from a specified location and return its filename.`version` should be a valid setuptools version number that is availableas an sdist for download under the `download_base` URL (which should endwith a '/'). `to_dir` is the directory where the egg will be downloaded.`delay` is the number of seconds to pause before an actual downloadattempt.``downloader_factory`` should be a function taking no arguments andreturning a function for downloading a URL to a target."""# making sure we use the absolute pathto_dir = os.path.abspath(to_dir)zip_name = "setuptools-%s.zip" % versionurl = download_base + zip_namesaveto = os.path.join(to_dir, zip_name)if not os.path.exists(saveto):  # Avoid repeated downloadslog.warn("Downloading %s", url)downloader = downloader_factory()downloader(url, saveto)return os.path.realpath(saveto)def _build_install_args(options):"""Build the arguments to 'python setup.py install' on the setuptools package.Returns list of command line arguments."""return ['--user'] if options.user_install else []def _parse_args():"""Parse the command line for options."""parser = optparse.OptionParser()parser.add_option('--user', dest='user_install', action='store_true', default=False,help='install in user site package')parser.add_option('--download-base', dest='download_base', metavar="URL",default=DEFAULT_URL,help='alternative URL from where to download the setuptools package')parser.add_option('--insecure', dest='downloader_factory', action='store_const',const=lambda: download_file_insecure, default=get_best_downloader,help='Use internal, non-validating downloader')parser.add_option('--version', help="Specify which version to download",default=DEFAULT_VERSION,)parser.add_option('--to-dir',help="Directory to save (and re-use) package",default=DEFAULT_SAVE_DIR,)options, args = parser.parse_args()# positional arguments are ignoredreturn optionsdef _download_args(options):"""Return args for download_setuptools function from cmdline args."""return dict(version=options.version,download_base=options.download_base,downloader_factory=options.downloader_factory,to_dir=options.to_dir,)def main():"""Install or upgrade setuptools and EasyInstall."""options = _parse_args()archive = download_setuptools(**_download_args(options))return _install(archive, _build_install_args(options))if __name__ == '__main__':sys.exit(main())

复制下来,弄到一个新txt文档里面,将txt文档改为ez_setup.py,这个文档的位置要和你Python的安装位置相同。和Python.exe在一个文件夹之下
进行下一步:
在cmd下执行 python ez_setup.py,(即:yyiyiyi>python ez_setup.py)
即可自动安装setuptools。目前没有直接的exe安装版本
成功之后,会有两个文件出现
这些文件会在Python27\Scripts文件夹之下(该文件夹在安装的时候自动创立),而不是在Python27\Tools\Scripts之下。

三. 下面继续安装nltk:用easy_install 安装(这步也会出问题)
利用cd D:\Python27\Scripts命令进入到含有easy_install .exe的文件夹
(进不去的话,需要关闭cmd模式,重新进入。这次这样设置

set PATH=%PATH%;D:\Python27)

numpy: easy_install numpy

pip: easy_install pip

nltk: easy_install nltk

如果一切正常,你就成功了
但咋会那么容易成功呢,win64真的是坑啊
numpy貌似可以安装成功
pip如果失败,可以先安装nltk,再安装pip
可以用如下方法安装pip,方法如下,
https://pypi.python.org/pypi/pip/,
去File里面找到pip-9.0.1.tar.gz (md5, pgp),解压到你的Python安装文件夹里面,利用cd D:\xxxx命令进入到D:\Python27\pip-9.0.1的文件夹,然后cmd里面输入
python setup.py install(记住cmd里面要对这个文件夹set path一次)
(参考 http://www.tuicool.com/articles/eiM3Er3/),
如果numpy之前成功了,就不用接下来的步骤

*然后再安装numpy
pip install numpy(方法没试过,参考http://www.itnose.net/detail/6200626.html等文章)*

四.之后系统可能会有一些warning提示,这些问题的处理较为简单,例如在C:\Users\Administrator下面建立pip文件夹,再建立pip.ini文件等等
参考(https://www.zhihu.com/question/52730764/answer/132143084)
其他有些问题记不太清了
最后就是打开python,进入nltk,下载data数据包(如果嫌慢的话,采用网盘下面的链接里有下载地址
引用自 http://www.jianshu.com/p/9c48e8edc7aa,在里面找到下载的地方,找到这么一段话(这里才是正确的下载方式:最好的方法是用使用@V_can打包好的的包网盘下载下载地址1:云盘密码znx7,下来的包nltk_data.zip 解压到C盘根目录下,这样是最保险的,防止找不到包。下载地址2:云盘密码4cp3))。
然后开始学习吧,祝成功,文章没法涵盖所有问题,请见谅。

win10 64位下Python中NLTK,pip,numpy等安装方法相关推荐

  1. win10 64位下Python最新版安装过程及破解

    1.下载python3.6.4,下载地址:https://www.python.org/getit/,找到Windows x86-64 executable installer,点击下载. 安装时建议 ...

  2. 从零点一开始机器学习之Win10 64位下安装Cuda+Cudnn

    系列文章目录 从零点一开始机器学习之晦涩难懂的各种概念 从零点一开始机器学习之Win10 64位下安装Cuda+Cudnn 从零点一开始机器学习之GPU运算性能和CPU性能对比(GPU算力表) 从零点 ...

  3. Win10 64位下解决 NVIDIA 显示设置不可用(小白问题)

    Win10 64位下解决 NVIDIA 显示设置不可用,您当前未使用连接到NVIDIA GPU 的显示器: 百度了一大片网上大佬给出好多个可能的问题: 1:右键点击我的电脑,右键选择属性.在弹出的页面 ...

  4. matlab2010 notebook,Matlab在Win10 64位下用notebook的问题

    Matlab在Win10 64位下用notebook,会弹出VB错误: Microsoft Visual Basic for Applications编译错误: 若要在64位系统上使用,则必须更新此项 ...

  5. 关于Win10 64位Cadence16.6中OrCAD Capture CIS导网表出现ERROR无效指针的解决办法

    ** 关于Win10 64位Cadence16.6中OrCAD Capture CIS导网表出现ERROR无效指针的解决办法 ***背景:在第一次使用Cadence原理图导网表,结果出现报错,PCB ...

  6. win10进lol无法连接服务器未响应,Win10 64位系统电脑中lol游戏无法连接服务器的处理方法...

    说到LOL游戏,相信很多小伙伴都会热血沸腾,这是一款非常受欢迎的网络游戏.不过有的小伙伴在win10 64位系统电脑中运行lol游戏时,发现老是会出现无法连接服务器的情况,这也让游戏玩家们很是苦恼,那 ...

  7. win10 64位下的小日本5(TMPGEnc Video Mastering Works)转码工具使用教程

    亲测可用!win10 64位下的小日本5(TMPGEnc Video MasteringWorks)转码工具,底部有重要的更新说明哦! [软件介绍] TMPGEnc Video Mastering W ...

  8. Win10 64位下GPU版本MXNet+Tensorflow 1.3.0的安装

    说明:本文记录时间为2017.7.23.在此时Tensorflow在Win下的安装要求为系统64位且Python版本为3.5(现已经支持py 3.6),MXNet在Win下只支持Python 2. 更 ...

  9. Win10 64位下 darknet YOLO V3配置,视频测试及结果保存

    环境如下: VS2015社区版 OpenCV3.4.0 (下载win pack链接:https://www.opencv.org/opencv-3-4.html) Win10 64位,i7-6700 ...

最新文章

  1. MCMC+马尔科夫链蒙特卡罗
  2. RabbitMQ-1
  3. windowslive writer 发布问题
  4. 项目: 打字母游戏图形化【C++ / C】
  5. AJAX Control Toolkit——DropShadow(阴影和圆角框)
  6. Castle动态代理拦截器可构建可重启的流
  7. Flex和Flash之间相互调用
  8. BAT中删除目录,如何不显示删除的文件
  9. paip.提升用户体验----应用程序调用外部字体的应用..
  10. SSM汽车销售平台的设计与实现毕业设计源码171619
  11. 沪江快速手机打字软件下载
  12. macOS pages 插入公式快捷键
  13. 什么叫嵌入式开发 嵌入式开发的要求
  14. 国外的一些开源网站汇集以及优秀博客的博客(非 CSDN的博客)
  15. GI 中新的基础架构 --MDNS, gipc 和 gpnp 是如何协同工作的
  16. Photoshop图层模式中英文对照及解释
  17. 尝试在blender中渲染一个最简单的动画
  18. Hive数据连接与函数(2)
  19. pandas之美国各州人口分析
  20. Python全局变量的隐藏“窍门”

热门文章

  1. 网站备案信息查询,如何通过网站底部查询网站备案信息
  2. 亚马逊cdn使用教程_如何使用亚马逊车库找到适合您汽车的零件
  3. 【opencv-python】大津法(Otsu)阈值分割原理深入分析
  4. 17 款程序员必备 Chrome扩展插件,爱了爱了
  5. mysql int字段 被转成Long问题解决
  6. idea社区版和企业版区别_idea社区版和商业版的区别
  7. iPhone 12:旧的不去,新的也没来
  8. Hive如何进入debug模式
  9. 阿里云servless实现身份证智能识别Demo
  10. 数据库mysql字段加换行_数据库字段换行