ImportError: /usr/local/lib/python3.2/dist-packages/pygame/base.cpython-32mu.so: undefined symbol: P

在我的ubuntu14.04系统上使用Python3.5安装pygame库时遇到了很多问题,我开始参考了《PYTHON编程:从入门到实践》里提供的安装方法,并不成功,之后在网上找了ubuntu安装pygame的方法如下:
1. Open up the terminal and type the following code:
sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev  libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion  libportmidi-dev
2. Then once all libraries are downloaded and installed, type:
svn co svn://seul.org/svn/pygame/trunk pygame
 cd pygame
 python3 setup.py build
 sudo python3 setup.py install








我按照以上方法执行以后,终端没有报错,但是当import pygame时却出现如下提示:ImportError: /usr/local/lib/python3.2/dist-packages/pygame/base.cpython-32mu.so: undefined symbol: PyCObject_Check










幸好在外网找到一篇帖子,题主遇到的问题和我如出一辙,最后题主找到了解决办法,转载如下:




问题:
So i tried installing pygame using this tutorial:
Code:
Okay, so I struggled for about an hour trying to get ‘ pygame ‘ run  with Python 3 on my ubuntu 11.04 machine, so I decided to write a post  about it.
By default, Ubuntu ships with Python 2.7 installed, so pygame gets installed with python 2.7.
To install it with python3, do the following:
1. Open up the terminal and type the following code:
sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev  libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion  libportmidi-dev
2. Then once all libraries are downloaded and installed, type:
svn co svn://seul.org/svn/pygame/trunk pygame
 cd pygame
 python3 setup.py build
 sudo python3 setup.py install
 3. That’s all! You can now run pygame with python3.
 I have also updated this on the pygame website, so that no one falls into this trouble again! 
And now when i trie to import it i get this:
Code:
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pygame
  File "/usr/local/lib/python3.2/dist-packages/pygame/__init__.py", line 95, in <module>
    from pygame.base import *
ImportError: /usr/local/lib/python3.2/dist-packages/pygame/base.cpython-32mu.so: undefined symbol: PyCObject_Check
Please HELP !!


解决方法:
I have pygame for python3.x installed on my desktop, but i redid my laptop and when i tried to install pygame for python3 i had a heck of time doing it. I also installed the python3-dev and sdl dependencies and removed the raw_input() to input(), but kept getting the error the OP stated.


So i checked my desktop and found that i was using pygame 1.9.2 pre and not 1.9.1. So with 1.9.2 pre i got it to to work on my laptop, which was a fresh install of ubuntu.


Here was my process:


0) downloaded 1.9.2 pre which took me a bit just to find:https://launchpad.net/debian/experim...44.orig.tar.gz


1) i had to remove pygame from python3's dist-packages, the pygame directory and the egg-info from 1.9.1
Code:
/usr/local/lib/python3.2/dist-packages
2) installed these (which i know some are non relavent, but i found it and just copied and pasted and installed anyways)
Code:
sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev  libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion  libportmidi-dev
3) then 
Code:
sudo python3 setup.py install
which by the way : no sudo and it will run and execute without errors, but you will still not be able toimport pygame, so sudo it


this is the python version i am using with this also:
Code:
metulburr@ubuntu:~$ python3 --version
Python 3.2.3


you will also get a message saying that some of the dependencies will not run, but i havent had a problem with anything for the past year on the desktop trying to run others programs or writing code myself with anything.


At this point import pygame was successful on my laptop


照题主提供的步骤执行以后,果然可以成功import了。原文网址:http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece763105187214512c7376197974a3ec3933fce240e5c063cbefe6178505380936b6776ed131efdf14234200256b490cc8a4ad9bb866d72c8713b2b43c41c52950eaebb1165817dd04de8df0ee6c9e732e2b9d3a0c854228d0f532dd4abd70d5603ca1eb15f6eb3fbc75f142f07bb9e27658e1b3c78882230eb17a1b76328108086ca5b38d42ba0304bc0fe6c&p=9165c21786cc46e90be2962f49&newp=99769a478f934ea81eaec0395453d8274e3980673ed7c44324b9d71fd325001c1b69e7bd20231605d1c07c6201a94359e8f53178301766dada9fca458ae7c471&user=baidu&fm=sc&query=ImportError%3A+%3A+undefined+symbol%3A+PyCObject%5FCheck&qid=e09bb55d0001db01&p1=1/c?m=9f65cb4a8c8507ed4fece763105187214512c7376197974a3ec3933fce240e5c063cbefe6178505380936b6776ed131efdf14234200256b490cc8a4ad9bb866d72c8713b2b43c41c52950eaebb1165817dd04de8df0ee6c9e732e2b9d3a0c854228d0f532dd4abd70d5603ca1eb15f6eb3fbc75f142f07bb9e27658e1b3c78882230eb17a1b76328108086ca5b38d42ba0304bc0fe6c&p=9165c21786cc46e90be2962f49&newp=99769a478f934ea81eaec0395453d8274e3980673ed7c44324b9d71fd325001c1b69e7bd20231605d1c07c6201a94359e8f53178301766dada9fca458ae7c471&user=baidu&fm=sc&query=ImportError%3A+%3A+undefined+symbol%3A+PyCObject%5FCheck&qid=e09bb55d0001db01&p1=1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误是一个ImportError,它指的是找不到一个名为"/usr/local/lib/python3.8/dist-packages/mmcv/_ext.cpython-38-x86_64-linux-gnu.so"的共享对象或动态链接库。具体的错误信息是"undefined symbol: Z27points_in_boxes_cpu_forwardN2at6TensorES0_S0"。 要解决这个问题,可以尝试使用ldd命令来查看"/usr/lib/python3/dist-packages/PyQt5/QtCore.cpython-37m-arm-linux-gnueabihf.so"依赖的库。可以在终端中输入"ldd /usr/lib/python3/dist-packages/PyQt5/QtCore.cpython-37m-arm-linux-gnueabihf.so"来查看。 另外,你还可以参考一个博客文章,链接为https://forums.linuxmint.com/viewtopic.php?f=47&t=291157,在这篇文章中有可能会提供一些关于解决这个问题的有用信息。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ImportError: /usr/local/anaconda3/envs/py38/lib/python3.8/site-packages/mmcv/_ext.cpython-38-x86_64-](https://blog.csdn.net/weixin_42130300/article/details/121616567)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [报错[ImportError: /usr/lib/python3/dist-packages/PyQt5/QtCore.cpython-37m-arm-linux-gnuea]](https://blog.csdn.net/mmmm0584/article/details/119382032)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值