安装Python包无需C++编译器。

huangapple go评论105阅读模式
英文:

Installing python package without a C++ compiler

问题

我正在尝试在没有C++编译器的Windows 7机器上运行HDBSCAN包。不幸的是,安装编译器不是一个选项。

我读到一些包有预编译的wheel文件,无需编译器即可安装。安装说明中提到:“由于Ryan Helinski的工作,许多平台都提供了二进制wheel文件”。然而,没有提到可以在哪里找到它们。我的问题是:

  1. 如何获取HDBSCAN包的.whl文件?
  2. 是否可以在另一台机器上编译+安装,然后复制它?如果可以,我在哪台机器上编译,这台机器与必须运行代码的机器有什么共同之处?可以在Windows 10机器上编译吗,还是必须也是Win7,两者是否需要运行相同的Windows更新,等等?
英文:

I'm trying to get the HDBSCAN package to run on a Windows 7 machine with no C++ compiler. Installing a compiler is not an option, unfortunately.
I read that some packages have precompiled wheel files that require no compiler to install. The installation notes state "Binary wheels for a number of platforms are available thanks to the work of Ryan Helinski". However, there is no mention of where those can be found. My questions are then:

  1. How do I obtain the .whl file for the HDBSCAN package?
  2. Is it possible to simply compile+install on another machine and copy it? If so, what should the machine on which I compile have in common with the one on which the code must run? Can I do it on a Windows 10 machine, or does it have to be Win7 as well, do the same Windows updates need to have been run on both, etc?

答案1

得分: 3

看起来项目维护者在PyPI上没有发布预先构建的_wheel_分发。

正如其他贡献者已经提到的,可以从第三方获取这样的_wheel_分发,比如Christoph Gohlke的“Python扩展包非官方Windows二进制文件”

当然,也可以在一台机器上构建这样的_wheel_,然后在另一台机器上重用它。据我所知,对于Windows,两台机器都需要具有相同的Python解释器(次要)版本以及相同的_bitness_(都是32位或都是64位)。操作系统的确切版本不应该有关紧要(从Windows 10到Windows 7或反之亦可正常工作)。

英文:

Looks like there is no pre-built wheel distribution published by the maintainers of the project themselves on PyPI.

As already mentioned by other contributors, one could get such wheel distributions from a third party such as Christoph Gohlke's "Unofficial Windows Binaries for Python Extension Packages".

It is also of course possible to build such wheels yourself on one machine and then reuse it on another. As far as I know in the case of Windows, both machines need to have the same Python interpreter (minor) version as well as the same bitness (both 32 bits or both 64 bits). The exact version of the operating system should not matter (from Windows 10 to Windows 7 or the other way around should work).

答案2

得分: 2

我最后通过在另一台机器上编译并复制该软件包来使其工作。关键是两台机器上所需的软件包版本必须相同,所以我只需设置一个新的conda环境,该环境与目标机器上的软件包版本相同,然后在那里使用pip安装hdbscan,最后复制到目标机器上。我担心Windows版本兼容性,但尽管我在Windows 10上安装并移动到运行Win7的机器上,但这也起效了。

英文:

I ended up getting this to work by compiling on another machine and copying the package from it. It was critical that the required packages were of the same version on both machines, so I simply set up a new conda environment which had the same package versions as the target machine, then intalled hdbscan with pip there, and copied.
I was worried about Windows version compatibility, but this worked even though I installed on Windows 10 and moved to a machine running Win7.

答案3

得分: 0

以下是要翻译的内容:

这里是您可以下载轮子文件的网站:https://www.lfd.uci.edu/~gohlke/pythonlibs/
适用于 Python 3.5 及更高版本
或者使用 PyPi 下载适用于较旧版本的文件

  • 运行命令 python -m pip install thefiledownloadedforyourpythonversion.whl

对于第二个问题,是的,您可以这样做,但这相对复杂,应尽量避免使用,除非必要。

英文:

here is the site you can download the wheel file :https://www.lfd.uci.edu/~gohlke/pythonlibs/
for python 3.5>
or PyPi for older versions

  • run python -m pip install thefiledownloadedforyourpythonversion.whl

For the second question , yes you can but is rather complicated and you should avoid it when you can 安装Python包无需C++编译器。

答案4

得分: -2

我刚刚检查了一下。Python 3.8 是用C编写的。你需要一个C编译器,而不是C++编译器。MINGW 是一个选择,TinyCC Win32 是另一个选择(它是一个小型编译器,生成速度较慢的可执行文件)。还可以查看这个列表,列出了一些免费的C或C++编译器。

一种可能性(可能需要几天的工作)是使用一些WSL 或一些Linux模拟器,比如JSLinux(它可以在Web浏览器中运行)。然后你可以(费力地)构建一个交叉编译器(首先从tinycc-win32开始,然后编译一个旧的交叉GCC 3编译器,然后使用它来编译一个更新的C++ GCC等等)。

但实际情况是,你不应该被允许这样做。你真正的问题是非技术性的:为什么你不能安装并使用一个C++编译器,比如MinGW?获取许可(和资源)来安装一个....

或者,考虑安装一些Linux发行版(确保你被允许这样做)。大多数Linux发行版都有最新的Python和GCC...

> 是否可能在另一台机器上编译+安装然后复制?

这被称为交叉编译,一般来说是可能的。关键是获得许可。你应该找到适合你情况的相关交叉编译工具。

如果允许的话,甚至可以使用一个Live Linux USB存储设备....

一些用Python编写的C编译器确实存在.... 你可以使用它们来交叉编译tinycc for Win32。然后你应该就有了一个Win32的C编译器。然后你可以编译一个旧版本的GCC等等。Qemu 在Windows上也存在。你可以在Qemu中运行一个带有交叉GCC编译器的Linux。

英文:

I just checked. Python 3.8 is coded in C. You need a C compiler, not a C++ one. MINGW is one, and TinyCC Win32 is another one (a small one, producing quickly slow executables). Look also into this list of free C or C++ compilers.

A possibility (which could take several days of work) might be to use some WSL or some Linux emulator such as JSLinux (it runs in a web browser). Then you could (painfully) build a cross compiler (starting first with a tinycc-win32, then compiling an old cross GCC 3 compiler, then compiling with that a newer C++ GCC, etc....)

But the reality is that you should not be allowed to do this. Your real issue is non technical: why are you not allowed to install then use a C++ compiler, such as MinGW? Get permission (and resources) to install some....

Alternatively, consider installing some Linux distribution (ensure you are allowed to do so). Most of them have a recent Python and GCC...

> Is it possible to simply compile+install on another machine and copy it?

This is called cross-compilation and is possible in general. The point is to be permitted to do that. You should find relevant cross-compilers for your situation.

If you are allowed to, you could even use a live Linux USB stick....

Some C compilers written in Python do exist.... You could use them to cross-compile tinycc for Win32. Then you should have a C compiler for Win32. You could then compile an old GCC, etc.... Qemu exist for windows. You could run a Linux with a cross-GCC compiler in Qemu.

huangapple
  • 本文由 发表于 2020年1月7日 01:34:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616517.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定