gpt4 book ai didi

python - 在 Windows 7 上将包安装到虚拟环境中

转载 作者:可可西里 更新时间:2023-11-01 10:06:00 28 4
gpt4 key购买 nike

我习惯于在 Mac 或 Linux 机器上编程,在这些机器上将软件包安装到虚拟环境中相对简单。不幸的是,Windows 似乎并非如此。我一直在尝试将 lxml 安装到 64 位 Windows 7 机器上的虚拟环境中。

首先我使用了 pip(我的首选工具):

(lxml_tutorial) PS C:\Users\spearsc\Documents\python_projects\lxml_tutorial> pip install lxml
Downloading/unpacking lxml
Running setup.py (path:c:\users\spearsc\appdata\local\temp\pip_build_spearsc\lxml\setup.py) egg_info for package lxml
Building lxml version 3.3.5.
Building without Cython.
ERROR: 'xslt-config' is not recognized as an internal or external command,
operable program or batch file.

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)

warning: no previously-included files found matching '*.py'
Installing collected packages: lxml
Running setup.py install for lxml
Building lxml version 3.3.5.
Building without Cython.
ERROR: 'xslt-config' is not recognized as an internal or external command,
operable program or batch file.

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
building 'lxml.etree' extension
gcc -mno-cygwin -mdll -O -Wall -Ic:\users\spearsc\appdata\local\temp\pip_build_spearsc\lxml\src\lxml\includes -IC:\P
ython27\include -IC:\Python27\PC -c src\lxml\lxml.etree.c -o build\temp.win-amd64-2.7\Release\src\lxml\lxml.etree.o -w
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
error: command 'gcc' failed: No such file or directory
Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\spearsc\\ap
pdata\\local\\temp\\pip_build_spearsc\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().rep
lace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\spearsc\appdata\local\temp\pip-c22v0y-record\install-r
ecord.txt --single-version-externally-managed --compile:
Building lxml version 3.3.5.

Building without Cython.

ERROR: 'xslt-config' is not recognized as an internal or external command,

operable program or batch file.



** make sure the development packages of libxml2 and libxslt are installed **



Using build configuration of libxslt

running install

running build

running build_py

creating build

creating build\lib.win-amd64-2.7

creating build\lib.win-amd64-2.7\lxml

copying src\lxml\builder.py -> build\lib.win-amd64-2.7\lxml

copying src\lxml\cssselect.py -> build\lib.win-amd64-2.7\lxml

copying src\lxml\doctestcompare.py -> build\lib.win-amd64-2.7\lxml

copying src\lxml\ElementInclude.py -> build\lib.win-amd64-2.7\lxml

copying src\lxml\pyclasslookup.py -> build\lib.win-amd64-2.7\lxml

copying src\lxml\sax.py -> build\lib.win-amd64-2.7\lxml

copying src\lxml\usedoctest.py -> build\lib.win-amd64-2.7\lxml

copying src\lxml\_elementpath.py -> build\lib.win-amd64-2.7\lxml

copying src\lxml\__init__.py -> build\lib.win-amd64-2.7\lxml

creating build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\__init__.py -> build\lib.win-amd64-2.7\lxml\includes

creating build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\builder.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\clean.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\defs.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\diff.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\ElementSoup.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\formfill.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\html5parser.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\soupparser.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\usedoctest.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\_diffcommand.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\_html5builder.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\_setmixin.py -> build\lib.win-amd64-2.7\lxml\html

copying src\lxml\html\__init__.py -> build\lib.win-amd64-2.7\lxml\html

creating build\lib.win-amd64-2.7\lxml\isoschematron

copying src\lxml\isoschematron\__init__.py -> build\lib.win-amd64-2.7\lxml\isoschematron

copying src\lxml\lxml.etree.h -> build\lib.win-amd64-2.7\lxml

copying src\lxml\lxml.etree_api.h -> build\lib.win-amd64-2.7\lxml

copying src\lxml\includes\c14n.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\config.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\dtdvalid.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\etreepublic.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\htmlparser.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\relaxng.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\schematron.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\tree.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\uri.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\xinclude.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\xmlerror.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\xmlparser.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\xmlschema.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\xpath.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\xslt.pxd -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\etree_defs.h -> build\lib.win-amd64-2.7\lxml\includes

copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-2.7\lxml\includes

creating build\lib.win-amd64-2.7\lxml\isoschematron\resources

creating build\lib.win-amd64-2.7\lxml\isoschematron\resources\rng

copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\
rng

creating build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl

copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl

copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl

creating build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win-amd64-2.7\lxm
l\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win-amd64-2.7\lxml\i
soschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win-amd64-2.7\
lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_skeleton_for_xslt1.xsl -> build\lib.win
-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win-amd64-2.7\lxml
\isoschematron\resources\xsl\iso-schematron-xslt1

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-2.7\lxml\isoschematr
on\resources\xsl\iso-schematron-xslt1

running build_ext

building 'lxml.etree' extension

creating build\temp.win-amd64-2.7

creating build\temp.win-amd64-2.7\Release

creating build\temp.win-amd64-2.7\Release\src

creating build\temp.win-amd64-2.7\Release\src\lxml

gcc -mno-cygwin -mdll -O -Wall -Ic:\users\spearsc\appdata\local\temp\pip_build_spearsc\lxml\src\lxml\includes -IC:\Pytho
n27\include -IC:\Python27\PC -c src\lxml\lxml.etree.c -o build\temp.win-amd64-2.7\Release\src\lxml\lxml.etree.o -w

C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

warnings.warn(msg)

error: command 'gcc' failed: No such file or directory

----------------------------------------
Cleaning up...
Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\spearsc\\appdata\\local\\temp\\pip_b
uild_spearsc\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __fil
e__, 'exec'))" install --record c:\users\spearsc\appdata\local\temp\pip-c22v0y-record\install-record.txt --single-versio
n-externally-managed --compile failed with error code 1 in c:\users\spearsc\appdata\local\temp\pip_build_spearsc\lxml
Storing debug log for failure in C:\Users\spearsc\pip\pip.log

我以前见过这个错误。我认为这是由于未设置 C 编译器引起的。根据以往的经验,我知道解决这个问题是一件非常痛苦的事情,所以我决定尝试另一种方法。

我去了http://www.lfd.uci.edu/~gohlke/pythonlibs/并下载了 lxml 的 exe 文件。然后我激活我的虚拟环境并在其中运行可执行文件。该库是全局安装的,这不是我想要的,所以我卸载了 lxml。

第三次尝试时,我激活了虚拟环境并使用 easy_install 安装 lxml。再一次,这个包被全局安装了!我用 pip 卸载了 lxml。

我真的很失望。我是否只需要在全局范围内安装我的所有软件包而忘记使用虚拟环境?我在网上看到的大多数解决方案似乎都已过时。

最佳答案

http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml 安装lxml 后,从 "C:/python/lib/site-packages",将以下文件复制并粘贴到您的虚拟环境“/lib/site-packages”。

  1. lxml(文件夹)
  2. lxml-3.3.5-py2.7.egg-info(文件夹)

关于python - 在 Windows 7 上将包安装到虚拟环境中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24318839/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com