接上文python-配置pip国内源,包含(windows/mac)
2.1.4. FLink安装包pip
- PyFlink包:一旦你有了Apache Flink和Python环境,你就可以通过pip或conda等包管理工具安装PyFlink包。运行以下命令即可安装PyFlink:
注意:这里网上有文章说是下载 pyflink ,是错误的,官方文档说要下载apache-flink
pip install apache-flink
或者
conda install -c conda-forge pyflink
- 配置文件:在安装完成后,你需要根据你的需求进行一些配置。主要的配置文件是flink-conf.yaml,它位于Flink的安装目录下的conf文件夹中。你可以根据需要调整配置项,如并行度、内存分配、检查点设置等。
- IDE或编辑器:为了编写和运行PyFlink程序,我们需要选择一个适合的集成开发环境(IDE)或文本编辑器。
- 常用的选择包括PyCharm、VS Code、Jupyter Notebook等。确保你在IDE或编辑器中正确配置了Python和PyFlink的环境。
换成清华源后:
pip install apache-flink -i Simple Index
2.1.6 安装报错
2.1.6.1. 报错1 :会报错提示 缺少 pycodestyle 包、缺少isort包等
可以手动安装
pip install --upgrade pip setuptools
pip install fastavro
pip install pycodestyle
pip install isort
pip install avro-python3
pip install numpy cython
pip install pandas
之后再运行 pip install apache-flink -i Simple Index
2.1.6.2. 报错2:....\pandas_libs\tslibs\meson.build:23:7: ERROR: Python dependency not found
..\..\pandas\_libs\tslibs\meson.build:23:7: ERROR: Python dependency not found
这个错误提示缺少 Python 依赖。可能是使用的 Python 版本不匹配或者环境配置有问题。
我们更新一下pip最后解决
- 尝试更新 pip 工具到最新版本,运行以下命令进行升级:
python -m pip install --upgrade pip
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [23 lines of output]
+ meson setup C:\Users\zhaoj\AppData\Local\Temp\pip-install-kfxst96b\pandas_06cc79a792274df6b61f388d2bb3b453 C:\Users\zhaoj\AppData\Local\Temp\pip-install-kfxst96b\pandas_06cc79a792274df6b61f388d2bb3b453\.mesonpy-vy8m87k4\build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --vsenv --native-file=C:\Users\zhaoj\AppData\Local\Temp\pip-install-kfxst96b\pandas_06cc79a792274df6b61f388d2bb3b453\.mesonpy-vy8m87k4\build\meson-python-native-file.ini
The Meson build system
Version: 1.2.1
Source dir: C:\Users\zhaoj\AppData\Local\Temp\pip-install-kfxst96b\pandas_06cc79a792274df6b61f388d2bb3b453
Build dir: C:\Users\zhaoj\AppData\Local\Temp\pip-install-kfxst96b\pandas_06cc79a792274df6b61f388d2bb3b453\.mesonpy-vy8m87k4\build
Build type: native build
Project name: pandas
Project version: 2.1.4
Activating VS 17.7.0
C compiler for the host machine: cl (msvc 19.37.32822 "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.37.32822 版")
C linker for the host machine: link link 14.37.32822.0
C++ compiler for the host machine: cl (msvc 19.37.32822 "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.37.32822 版")
C++ linker for the host machine: link link 14.37.32822.0
Cython compiler for the host machine: cython (cython 0.29.37)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python found: YES (D:\Environment\python3.10\python.exe)
Need python for x86_64, but found x86
Run-time dependency python found: NO (tried sysconfig)
..\..\pandas\_libs\tslibs\meson.build:23:7: ERROR: Python dependency not found
A full log can be found at C:\Users\zhaoj\AppData\Local\Temp\pip-install-kfxst96b\pandas_06cc79a792274df6b61f388d2bb3b453\.mesonpy-vy8m87k4\build\meson-logs\meson-log.txt
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
[notice] A new release of pip available: 22.3.1 -> 23.3.2
[notice] To update, run: python.exe -m pip install --upgrade pip
2.1.6.3. windows报错3:python安装包不是64位
如果出现如下错误,应该是Pythonan安装不是64位
C compiler for the host machine: cl (msvc 19.37.32822 "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.37.32822 版") C linker for the host machine: link link 14.37.32822.0 C++ compiler for the host machine: cl (msvc 19.37.32822 "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.37.32822 版") C++ linker for the host machine: link link 14.37.32822.0
windows 应该下载64位python
mac不用管
2.1.6.4. mac报错:错误提示了一个与 xcrun 相关的问题。
mac报错:vrorunning build_extCompiling fastavro/_read.pyx because it changed[1/1] Cythonizing fastavro/_read.pyxbuilding'fastavro._read' extensioncreating build/temp.macosx-10.9-x86_64-cpython-39creating build/temp.macosx-10.9-x86_64-cpython-39/fastavroclang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapV -02 -Wall -fPIC -02 -isystem /Users/xiaozixiang/opt/anaconda3/include -arch x86_64 -I/Users/xiaozixiang/opt/anaconda3/include -fPIC -02 -isystem /Users/xiaozixiang/opt/anaconda3/include -arch x86_64 -I/Users/xiaozixiang/opt/anaconda3/include/python3.9 -c fastavro/_read.c -o build/temp.macosx-10.9-x86_64-cpython-39/fastavro/_read.oxcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrunerror: command'/usr/bin/clang’ failed with exit code 1end of output] note: This error originates from a subprocess, and is likely not a problem witpip.ERROR: Failed building wheel for fastavroFailed to build fastavroERROR: Could not build wheels for fastavro, which is required to install pyproject.toml-basedprojects
这里的xcrun 是 macOS 开发工具包(Command Line Tools)的一部分,它提供了一些开发所需的命令行工具。错误中指出了一个无效的 active developer path,这可能意味着 Command Line Tools 没有正确安装或配置。
要解决这个问题,可以尝试以下步骤:
- 确保已经安装了 Xcode 或者 Command Line Tools。你可以在终端中运行 xcode-select --install 命令来安装 Command Line Tools。
- 如果已经安装了 Xcode 或 Command Line Tools,但仍然遇到此错误,请尝试重新安装或更新它们。你可以通过 App Store 下载和安装 Xcode,或者使用终端中的 softwareupdate --all --install --force 命令来更新 Command Line Tools。
- 如果上述步骤都没有解决问题,可以尝试手动设置 active developer path。在终端中运行以下命令:sudo xcode-select -s /Applications/Xcode.app/Contents/Developer,将路径替换为你的 Xcode 安装路径。
2.1.7. flink安装成功:
版权归原作者 叶沧ii 所有, 如有侵权,请联系我们删除。