win10的pycharm中安装ansible模块过程
前面的安装报错信息
ansible模块安装报错:Could not install packages due to an OSError: [Errno 2] No such file or directory:
先升级pip版本,如果不指定国内源,容易更新失败
(venv) D:\python_mcw\venv\Scripts>D:\python_mcw\venv\Scripts\python.exe -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
然后设置里安装ansible失败
pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ ansible 设置里执行的命令
Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'D:\python_mcw\venv\Scripts\python.exe'.
执行命令还是出现问题:
(venv) D:\python_mcw\venv\Scripts>D:\python_mcw\venv\Scripts\pip.exe install ansible -i https://pypi.tuna.tsinghua.edu.cn/simple/
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ac/17/cb3ae6e4ae5b2d936ec5bf7e20cb91814e3af3ed27bbfcdf8a7253a016d5/ansible-4.8.0.tar.gz (36.1 MB)
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-3nnxfuc8\\ansible_b5e66e8954384775acff7f9696d7e583\\ans
ible_collections/amazon/aws/tests/unit/plugins/modules/placebo_recordings/cloudformation/client_request_token_s3_stack/cloudformation.DescribeStackEvents_1.json'
HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
按照提示是系统不支持长路径,需要打开功能:https://pip.pypa.io/warnings/enable-long-paths
cmd:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001
powershell:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
这里我 桌面上ctrl +shift 右击,打开powershell 执行命令,这个问题就没了,下面是变成另一个问题了
ansible下載地址:https://releases.ansible.com/ansible/
这里我 下载了ansible 2.9.17的包,后面从其它地方下载其它版本包用下面方法安装就成功了
成功安装前的错误信息
我在win10的pycharm上装ansible模块,准备学习写ansible插件用 ,但是pycharm上pip安装不了呀,怎么试都是这个报错,有大佬知道怎么解决吗?我找了网上的信息了,没看到有效的解决方法。
error: can't copy 'lib\ansible\module_utils\ansible_release.py': doesn't
exist or not a regular file
报错详情:
.........
copying lib\ansible\modules\wait_for_connection.py -> build\lib\ansible\modules
copying lib\ansible\modules\yum.py -> build\lib\ansible\modules
copying lib\ansible\modules\yum_repository.py -> build\lib\ansible\module
s
copying lib\ansible\modules_init_.py -> build\lib\ansible\modules
creating build\lib\ansible\module_utils
error: can't copy 'lib\ansible\module_utils\ansible_release.py': doesn't
exist or not a regular file
----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\python_mcw\venv\Scripts\py
thon.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"
'C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-nzxalbzo\ansible-core_305a73fdeb1b456395fe17a9510839d2\setup.py'"'"'; file='"'"'C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-nzxa
lbzo\ansible-core_305a73fdeb1b456395fe17a9510839d2\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup;
setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-gaqrbj71\i
nstall-record.txt' --single-version-externally-managed --compile --install-headers 'D:\python_mcw\venv\include\site\python3.6\ansible-core' Check the logs for full command output.
成功安装的过程
windows下使用pycharm开发基于ansible api的python程序
Window下python安装ansible,基于ansible api开发python程序#
在windows下使用pycharm开发基于ansible api的python程序时,发现ansible的包无法import。本机安装的是3.7.0的python,cmd下使用pip安装ansible一直安装失败。pycharm中使用File | Settings | Project: runTasks | Project Interpreter也无法导入ansible的包。后来终于找到解决方法。
下载ansible压缩包:https://files.pythonhosted.org/packages/ec/ee/1494474b59c6e9cccdfde32da1364b94cdb280ff96b1493deaf4f3ae55f8/ansible-2.7.1.tar.gz
解压到python安装路径下,例如(D:\python_mcw\venv\Scripts\ansible-2.7.1);
以管理员身份运行cmd,cd到上面的安装路径下,输入d:\python_mcw\venv\Scripts\python.exe setup.py install,即可用安装成功;
然后进入pycharm项目中,再次import ansible的包就可以了。
备注:之前用ansible 2.9.17的包还是不行,报错,怀疑是ansible包的问题,于是换成2.7.1的,果然是可以了。
执行成功如下:
Using d:\python_mcw\venv\lib\site-packages
Finished processing dependencies for ansible==2.7.1
前面有个语法报错忽略掉没影响:
File "d:\python_mcw\venv\lib\site-packages\ansible-2.7.1-py3.6.egg\ansible\modules\clustering\openshift\_openshift_scale.py", line 1
../k8s/k8s_scale.py
^
SyntaxError: invalid syntax
安装完之后可以看到python虚拟环境中已经生成了ansible的 目录了D:\python_mcw\venv\Lib\site-packages\ansible-2.7.1-py3.6.egg\ansible
不知道是不是可以直接复制目录到其它虚拟环境使用呢,有时间验证下
进入pycharm,import ansible 没导入成功,关闭pycharm重新打开项目,就可以成功导入ansible模块
这个 模块的安装过程,如果包没有问题,也可以用这个方式安装其它python第三方模块
参考链接:https://www.cnblogs.com/ryxiong-blog/p/11245756.html
win10的pycharm中安装ansible模块过程的更多相关文章
- win10在Pycharm中安装scrapy
查看官网说明 发现推荐是安装Anaconda 或 Miniconda,这东西有点大而全,感觉目前用不上.所以没这样做. 直接安装scrapy 如果直接装会报错的,参考文章就可以解决. 这里记一下组件下 ...
- PyCharm中导入MySQLDB模块小结
安装完MySQL-python驱动,在PyCharm中导入MySQLDB模块一直不成功 Settings里面也没有MySQLdb 百般尝试找解决办法,一直搞不定,最后抱着试一试的心态尝试了一个办法: ...
- 【Python】在Pycharm中安装爬虫库requests , BeautifulSoup , lxml 的解决方法
BeautifulSoup在学习Python过程中可能需要用到一些爬虫库 例如:requests BeautifulSoup和lxml库 前面的两个库,用Pychram都可以通过 File--> ...
- 关于pycharm中安装第三方库时报错的解决办法(一)
记录自己的生活! 一.事发背景 在pycharm中直接安装第三方库时因为版本问题总是无法安装成功,事情不大,但是很重要. 二.经过 最开始我自己电脑上安装了Python3.6和Python2. ...
- pycharm中使用redis模块入门
数据缓存系统:1:mongodb:是直接持久化,直接存储于硬盘的缓存系统2:redis: 半持久化,存储于内存和硬盘3:memcache:数据只能存储在内存里的缓存系统 redis是一个key-val ...
- 在Pycharm中导入第三方模块库(诸如:matplotlib、numpy等)
在Pycharm中导入第三方模块库 一.打开pycharm: 二.点击菜单上的“file” -> “setting”: 三.步骤二完成后出现界面如下所示.选中你的项目(比如thisyan Pro ...
- ansible笔记(1)在centos中安装ansible
ansible笔记():ansible的基本概念 一些基础概念 ansible是什么? 它是一个"配置管理工具",它是一个"自动化运维工具",如果你没有使用过任 ...
- 5.pycharm中导入第三方模块的方法
最近刚入门学习python,网上查找了一些资料,发现python编程用的软件pycharm还是比较多的,于是就跟随大众,学习使用pycharm,在学习的过程中,想要导入第三方模块pyperclip,但 ...
- 在Centos7.x中安装psutil模块
一.window10操作系统(Python 3.6开发环境)安装psutil 1.安装psutil模块 wget https://pypi.python.org/packages/source/p/p ...
随机推荐
- MacOS下Java与JDK关系与相关路径
MacOS下Java与JDK关系与相关路径 macOS下的Java与JDK的路径曾经困扰过我一段时间,今天稍有些忘记,故记下笔记,整理一下.Java与JDK的关系不在本文笔记之内,Javaer常识. ...
- js Promise用法
Promise 英文意思是 承诺的意思,是对将来的事情做了承诺, Promise 有三种状态, Pending 进行中或者等待中 Fulfilled 已成功 Rejected 已失败 Promise ...
- Web前端安全之安全编码原则
随着Web和移动应用等的快速发展,越来越多的Web安全问题逐渐显示出来.一个网站或一个移动应用,如果没有做好相关的安全防范工作,不仅会造成用户信息.服务器或数据库信息的泄露,更可能会造成用户财产的损失 ...
- javascript-jquery对象的动画处理
一.显示与隐藏动画效果 1.hide(动画持续时间,easing用来指定切换效果,动画执行完毕调用函数): $("p").hide(5000,"swing",f ...
- 想要彻底搞懂大厂是如何实现Redis高可用的?看这篇文章就够了!(1.2W字,建议收藏)
高可用HA(High Availability)是分布式系统架构设计中必须考虑的因素之一,它通常是指,通过设计减少系统不能提供服务的时间. 假设系统一直能够提供服务,我们说系统的可用性是100%.如果 ...
- 脚本注入1(boolean&&get)
现在,我们回到之前,练习脚本支持的布尔盲注(get型). 布尔盲注的应用场景是查询成功和失败时回显不同,且存在注入点的地方. 这里以Less-8为例: 发现查询成功时,会显示:失败则无回显. 同时发现 ...
- The WebSocket session [0] has been closed and no method (apart from close()) may be called on a closed session-ConcurrentHashMap使用在webSocket中采的坑
一.问题由来 现在开发的一个项目中使用webSocket这个技术和Unity客户端程序进行联动操作,因为socket连接相对来说比http请求连接更加的快速,而且是 一个长链接,方便于这个项目进行其他 ...
- 使用cerebro可视化ElasticSearch集群信息
使用cerebro可视化ElasticSearch集群信息 一.背景 二.安装步骤 1.下载并解压 2.配置cerebro 3.启动 cerebro 4.启动界面 三.注意事项 四.参考文档 一.背景 ...
- Python课程笔记(六)
今天上课补上了上次未学完比较重点的鼠标和键盘事件,同时开始学习运用turtle进行绘图. 本次课程的代码: https://gitee.com/wang_ming_er/python_course_l ...
- MyBatis源码分析(二):MyBatis整体架构及原理
一.Mybatis整体架构导图 二.Mybatis的核心组成 SqlSessionFactoryBuilder(构造器): 根据配置信息(XML)生成SqlSessionFactory工厂接口,构造器 ...