使用 conda 在 Windows 上构建 Python 包时出现奇怪的“拒绝访问”错误
Posted
技术标签:
【中文标题】使用 conda 在 Windows 上构建 Python 包时出现奇怪的“拒绝访问”错误【英文标题】:Strange "Access Denied" error when building a Python package on Windows using conda 【发布时间】:2019-08-17 22:15:06 【问题描述】:我正在尝试构建 Chaco
包,使用:
conda build --numpy=1.16 --use-local conda.recipe\chaco
我在构建过程中遇到了这个非常奇怪的错误:
Using c:\programdata\anaconda3\conda-bld\chaco_1566078508037\_h_env\lib\site-packages
Searching for fonttools==3.44.0
Best match: fonttools 3.44.0
Adding fonttools 3.44.0 to easy-install.pth file
Installing fonttools-script.py script to %BUILD_PREFIX%\Scripts
Installing fonttools.exe script to %BUILD_PREFIX%\Scripts
error: [WinError 5] Access is denied: 'C:\\ProgramData\\Anaconda3\\conda-bld\\chaco_1566078508037\\_h_env\\Scripts\\font
tools.exe'
(%BUILD_PREFIX%) %SRC_DIR%>if errorlevel 1 exit 1
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\conda-build-script.py", line 10, in <module>
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\cli\main_build.py", line 445, in main
execute(sys.argv[1:])
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\cli\main_build.py", line 436, in execute
verify=args.verify, variants=args.variants)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\api.py", line 209, in build
notest=notest, need_source_download=need_source_download, variants=variants)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\build.py", line 2324, in build_tree
notest=notest,
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\build.py", line 1439, in build
windows.build(m, build_file, stats=build_stats, provision_only=provision_only)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\windows.py", line 294, in build
check_call_env(cmd, cwd=m.config.work_dir, stats=stats, rewrite_stdout_env=rewrite_env)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\utils.py", line 397, in check_call_env
return _func_defaulting_env_to_os_environ('call', *popenargs, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\utils.py", line 377, in _func_defaulting_env_to_os_enviro
n
raise subprocess.CalledProcessError(proc.returncode, _args)
subprocess.CalledProcessError: Command '['cmd.exe', '/d', '/c', 'conda_build.bat']' returned non-zero exit status 1.
但是,当我检查C:\ProgramData\Anaconda3\conda-bld\chaco_1566078508037\_h_env\Scripts\
目录的内容时,我看到了fonttools.exe
文件:
(base) C:\Users\dbanas\Documents\GitHub\PyBERT>dir C:\ProgramData\Anaconda3\conda-bld\chaco_1566078508037\_h_env\Scripts
Volume in drive C has no label.
Volume Serial Number is FCC9-2CA2
Directory of C:\ProgramData\Anaconda3\conda-bld\chaco_1566078508037\_h_env\Scripts
08/17/2019 02:50 PM <DIR> .
08/17/2019 02:50 PM <DIR> ..
08/09/2019 04:35 PM 74 2to3-script.py
07/23/2019 09:00 AM 40,960 2to3.exe
07/15/2019 09:09 AM 215 cygdb-script.py
01/26/2019 07:02 PM 40,960 cygdb.exe
07/15/2019 09:09 AM 236 cython-script.py
01/26/2019 07:02 PM 40,960 cython.exe
07/15/2019 09:09 AM 216 cythonize-script.py
01/26/2019 07:02 PM 40,960 cythonize.exe
04/29/2019 08:08 AM 225 easy_install-script.py
01/26/2019 07:02 PM 40,960 easy_install.exe
08/17/2019 02:49 PM 441 f2py-script.py
05/21/2019 02:14 PM 156 f2py.bat
05/29/2019 07:49 AM 74,752 f2py.exe
08/17/2019 02:50 PM 463 fonttools-script.py
07/19/2019 01:00 PM 74,752 fonttools.exe
08/09/2019 04:35 PM 72 idle-script.py
07/23/2019 09:00 AM 40,960 idle.exe
05/10/2019 08:22 AM 207 pip-script.py
01/26/2019 07:02 PM 40,960 pip.exe
08/09/2019 04:35 PM 57 pydoc-script.py
07/23/2019 09:00 AM 40,960 pydoc.exe
08/17/2019 02:49 PM 200 pyftinspect-script.py
07/19/2019 01:00 PM 74,752 pyftinspect.exe
08/17/2019 02:49 PM 198 pyftmerge-script.py
07/19/2019 01:00 PM 74,752 pyftmerge.exe
08/17/2019 02:49 PM 199 pyftsubset-script.py
07/19/2019 01:00 PM 74,752 pyftsubset.exe
08/17/2019 02:49 PM 199 pygmentize-script.py
07/19/2019 01:00 PM 74,752 pygmentize.exe
08/17/2019 02:49 PM 196 ttx-script.py
07/19/2019 01:00 PM 74,752 ttx.exe
05/14/2019 11:39 AM 203 wheel-script.py
01/26/2019 05:02 PM 40,960 wheel.exe
33 File(s) 895,461 bytes
2 Dir(s) 168,398,778,368 bytes free
因此,很明显,构建过程没有拒绝访问。
当这第一次发生时,我想,“哦,哦!Anaconda3 安装损坏了。” 因此,我卸载了 Anaconda3,确保我在所有 Windows (7-Pro) 更新上都是最新的,重新启动并重新安装了 Anaconda3。 我得到完全相同的错误!
我的conda.recipe\chaco\meta.yaml
文件内容,供参考:
package:
name: chaco
version: "4.8.0"
source:
path: ../../chaco/
# fn: chaco-4.6.1.tar.gz
# url: https://pypi.python.org/packages/d8/5f/82539366bb321f6f07fada6278e320bb52916a36b43fbe0e30e5ef9f9166/chaco-4.6.1.tar.gz
# md5: d28117730f942f7cecb281b07abac3f4
# patches:
# List any patch files here
# - fix.patch
build:
# noarch_python: True
# preserve_egg_dir: True
# entry_points:
# Put any entry points (scripts to be generated automatically) here. The
# syntax is module:function. For example
#
# - chaco = chaco:main
#
# Would create an entry point called chaco that calls chaco.main()
# If this is a new build for the same version, increment the build
# number. If you do not include this key, it defaults to 0.
number: 2
requirements:
build:
- python
- setuptools
- enable >=4.8.0,<4.9
- cython
- pillow
run:
- python
- enable >=4.8.0,<4.9
- cython
- pillow
test:
# Python imports
imports:
- chaco
- chaco.contour
- chaco.downsample
- chaco.downsample.tests
- chaco.layers
- chaco.overlays
- chaco.plugin
- chaco.scales
- chaco.scales.tests
- chaco.shell
- chaco.tests
- chaco.tools
- chaco.tools.tests
- chaco.tools.toolbars
- chaco.ui
# commands:
# You can put test commands to be run here. Use this to test that the
# entry points work.
# You can also put a file called run_test.py in the recipe that will be run
# at test time.
# requires:
# Put any additional test requirements here. For example
# - nose
about:
home: http://docs.enthought.com/chaco
license: BSD License
summary: 'interactive 2-dimensional plotting'
license_family: BSD
# See
# http://docs.continuum.io/conda/build.html for
# more information about meta.yaml
还有我的bld.bat
:
"%PYTHON%" setup.py install
if errorlevel 1 exit 1
:: Add more build steps here, if they are necessary.
:: See
:: http://docs.continuum.io/conda/build.html
:: for a list of environment variables that are set during the build process.
根据this post 中的建议,我尝试卸载 Anaconda3 并重新安装“只为我”,这具有在我的主目录下安装 Anaconda3 的效果。
行为没有变化:仍然收到同一文件的“访问被拒绝”错误:fonttools.exe
。
问题: 有没有办法可以进入Chaco
构建目录并手动完成构建/上传,这样我就可以在等待的同时发布此 PyBERT 更新的 Windows 版本回复我的帖子?
【问题讨论】:
看起来有点类似于在 Windows 上困扰 R 包安装很长一段时间的错误:由于防病毒软件同时扫描目录,R 无法重命名目录。在 IIUC,Anaconda 正在尝试移动一个 exe 文件:它是否也与防病毒软件有关?您可以尝试在构建期间关闭 AV。 @Jean-ClaudeArbaut,感谢您的建议。我尝试暂时关闭我的杀毒软件,但没有任何乐趣;我得到完全相同的行为。 :( 【参考方案1】:FWIW - 在您在 Anaconda 中找到解决方案之前,另一种可能的解决方法是使用 Enthought 部署管理器 (EDM) 安装环境,该管理器在 Win/Lin/Mac 上为 CPython 2.7.15、3.5 提供 chaco 4.8.0 .2 和 3.6.5 EDM Product Description and Download, EDM Documentation
【讨论】:
其实 3.6.5 已经可以使用了@dbanas以上是关于使用 conda 在 Windows 上构建 Python 包时出现奇怪的“拒绝访问”错误的主要内容,如果未能解决你的问题,请参考以下文章