<cite id="9vvnb"></cite>
<cite id="9vvnb"></cite>
<var id="9vvnb"><strike id="9vvnb"></strike></var>
<menuitem id="9vvnb"><strike id="9vvnb"><listing id="9vvnb"></listing></strike></menuitem>
<cite id="9vvnb"><video id="9vvnb"></video></cite>
<cite id="9vvnb"></cite>
<cite id="9vvnb"><video id="9vvnb"></video></cite>
<var id="9vvnb"></var>
<cite id="9vvnb"></cite><cite id="9vvnb"><span id="9vvnb"></span></cite>
<cite id="9vvnb"><span id="9vvnb"><menuitem id="9vvnb"></menuitem></span></cite>

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第三方模塊

 參考鏈接:http://www.m3gworks.com/ryxiong-blog/p/11245756.html

 

某次報錯解決過程PyCharm venv失?。骸盁o此選項:--build-dir”

解決方法:

PyCharm依賴于--build- dir安裝軟件包,該標志在最新的20.3版中已刪除pip。

PyCharm的修復程序已準備就緒,并將在本周以2020.3版本發布(并移植到2020.2.5和2020.1.5)。

解決方法是降級pip到以前的版本-關閉PyCharm并python -m pip install pip==20.2.4使用相應的虛擬環境在終端中運行。

 

終端上更新了pip,site-包目錄下生成pip-21.3.1.dist-info目錄
將site-包下的pip和pip-21.3.1.dist-info目錄改名,pip -V就找不到模塊了
ModuleNotFoundError: No module named 'pip'
把pip目錄改回名字,正常返回,并且能正常安裝模塊,貌似pip-21.3.1.dist-info目錄下只有文件,文件是沒有用處的。終端上安裝之后,setting里面也顯示出剛剛裝的模塊。site-包目錄下也多了對應的包目錄
(venv) D:\projs\machangwei1\venv\Scripts>pip -V
pip 21.3.1 from D:\projs\machangwei1\venv\lib\site-packages\pip (python 3.6)
雖然pip-21.3.1.dist-info目錄沒有改回名字,但是setting顯示包的地方,下面一行黃色字,python包工具不能找到,安裝包工具。
點擊安裝,事件日志:Packages installed successfully: Installed Python packaging tools。然后黃色字消失,但是site-包目錄下多了“pip-10.0.1-py3.6.egg”目錄,
pycharm左上角點擊關閉項目,所有項目都沒關閉,回到剛剛安裝然后進入創建項目的頁面,此時安裝requests模塊成功,隨便選的那個提示要更新pip,打開原來的machangwei2項目也是可以安裝這個模塊的
然后按照ansible模塊在machangwei2項目上,報錯:
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:\projs\machangwei2\venv\Scripts\python.exe'.
Command "D:\projs\machangwei2\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Administrator\\AppData\\Local\\Temp\\pycharm-packaging\\cryptography\\setup.py';f=getattr(tokenize, 'open', open)(__file__);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-0qjmrtvi\install-record.txt --single-version-externally-managed --compile --install-headers D:\projs\machangwei2\venv\include\site\python3.6\cryptography" failed with error code 1 in C:\Users\Administrator\AppData\Local\Temp\pycharm-packaging\cryptography\
You are using pip version 10.0.1, however version 21.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

可用的包窗口,安裝pip.解釋器窗口pip還是10版本,但是后面可以的包多了最新版本,選擇pip點擊右邊的升級。升級失敗,但是解釋器窗口顯示 版本是最新,錯誤信息忘記復制了。重新安裝request報錯no such option: --build-dir
安裝低版本python -m pip install pip==20.2.4
可以看到解釋器窗口也成為低版本的了。再次在可用包窗口安裝requests模塊,成功安裝。原來是pip版本問題導致的可用包窗口無法安裝模塊,即21.3.1版本


參考鏈接:https://codingdict.com/questions/194677

 

 

 



 

 

2.8 ansible AIP開發:https://www.jianshu.com/p/ec1e4d8438e9

 2.9 官網api事例:https://docs.ansible.com/ansible/latest/dev_guide/developing_api.html

posted @ 2021-11-20 21:28  馬昌偉  閱讀(323)  評論(0編輯  收藏  舉報
黄色网站在现免费看_黄色网站在线18P_黄色网站在线播放