找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 10214|回复: 2

[已解决] 导入numpy模块的问题

[复制链接]
发表于 2021-6-28 11:33:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 Zealot001 于 2021-6-28 15:12 编辑

按照官方文档给出的方法
pip2 install --target game/python-packages requests
我已经成功导入了requests模块
[RenPy] 纯文本查看 复制代码
init -1 python:
    import requests

单纯导入requests模块游戏可以正常运行
但是按照相同的方法,导入numpy模块
pip2 install --target game/python-packages numpy
游戏运行就会出现问题
[RenPy] 纯文本查看 复制代码
init -1 python:
    import requests
    import numpy as np 


[RenPy] 纯文本查看 复制代码
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script/mainfun.rpy", line 1, in script
    init -1 python:
  File "game/script/mainfun.rpy", line 1, in script
    init -1 python:
  File "game/script/mainfun.rpy", line 3, in <module>
    import numpy as np
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
  your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
  1. Check that you are using the Python you expect (you're using D:/renpy/renpy-7.4.6-sdk/lib/windows-x86_64\pythonw.exe),
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy versions you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     [url=https://github.com/numpy/numpy/issues.]https://github.com/numpy/numpy/issues.[/url]  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

     Note: this error has many possible causes, so please don't comment on
     an existing issue about this - open a new one instead.

Original error was: No module named _multiarray_umath


按照traceback给出的方案排查,安装python2的方式,电脑的操作系统,安装多版本python应该都没有问题
但我重新用pip安装numpy(版本号1.16.6),仍然报错
具体是什么原因,实在是搞不清了,求大佬解答


发表于 2021-6-28 13:50:21 | 显示全部楼层
numpy是一个依赖于C语言源码的库,所以不能直接使用文档中的方式引用。
目前看到的说法,如果要引入这种库,需要在Ren'Py源码中就引入,并重新编译Ren'Py引擎
但连Ren'Py的主创Tom都觉得“building Ren'Py is really hard”。
回复 支持 抱歉

使用道具 举报

 楼主| 发表于 2021-6-28 15:12:26 | 显示全部楼层
被诅咒的章鱼 发表于 2021-6-28 13:50
numpy是一个依赖于C语言源码的库,所以不能直接使用文档中的方式引用。
目前看到的说法,如果要引入这种库 ...

原来如此,感谢!
回复 支持 抱歉

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|RenPy中文空间 ( 苏ICP备17067825号|苏公网安备 32092302000068号 )

GMT+8, 2024-11-22 20:39 , Processed in 0.127002 second(s), 24 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表