简体   繁体   English

无法安装Python包

[英]Can't install a Python package

I'm very new to CentOS and I am trying to install the M2Crypto Python package on it. 我是CentOS的新手,我正在尝试在其上安装M2Crypto Python软件包。

I ran: 我跑了:

sudo python setup.py install

And it appeared to go ok: (this is the end of the output) 它似乎没问题:(这是输出的结束)

removing 'build/bdist.linux-i686/egg' (and everything under it)
Processing M2Crypto-0.20.2-py2.4-linux-i686.egg
Removing /usr/lib/python2.4/site-packages/M2Crypto-0.20.2-py2.4-linux-i686.egg
Copying M2Crypto-0.20.2-py2.4-linux-i686.egg to /usr/lib/python2.4/site-packages
M2Crypto 0.20.2 is already the active version in easy-install.pth

Installed /usr/lib/python2.4/site-packages/M2Crypto-0.20.2-py2.4-linux-i686.egg
Processing dependencies for M2Crypto==0.20.2

However I can't import M2Crypto: 但是我无法导入M2Crypto:

$ python
Python 2.4.3 (#1, Nov 11 2010, 13:34:43) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import M2Crypto
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "M2Crypto/__init__.py", line 22, in ?
import __m2crypto
ImportError: No module named __m2crypto
>>> 

What am I doing wrong? 我究竟做错了什么?

I ran: 我跑了:

python setup.py tests

and that fixed it. 并修复了它。 It copied some files, which I think resulted in the lib being put in the right place. 它复制了一些文件,我认为这会导致lib放在正确的位置。

running test
running egg_info
writing M2Crypto.egg-info/PKG-INFO
writing top-level names to M2Crypto.egg-info/top_level.txt
writing dependency_links to M2Crypto.egg-info/dependency_links.txt
reading manifest file 'M2Crypto.egg-info/SOURCES.txt'
writing manifest file 'M2Crypto.egg-info/SOURCES.txt'
running build_ext
copying build/lib.linux-i686-2.4/M2Crypto/__m2crypto.so -> M2Crypto
test_BitSTring (tests.test_asn1.ASN1TestCase) ... ok
.
.
.

tests isn't a valid target, run test instead; tests不是有效的目标,而是运行test ; that fixed the problem for me. 这解决了我的问题。

I just ran into the same issue, on centos 6.2. 我刚刚在centos 6.2上遇到了同样的问题。

Running test also fixed it for me. 跑步测试也为我修好了。 However when I looked in site packages, nothing was changed. 但是,当我查看网站包时,没有任何改变。 Running setup.py test builds m2crpyto in the local directory. 运行setup.py test会在本地目录中构建m2crpyto。

That's the key to the problem, to fix the issue without running setup.py test, leave the M2Crypto folder. 这是问题的关键,在不运行setup.py测试的情况下修复问题,离开M2Crypto文件夹。 It's picking up m2crypto from the local folder, and not finding the egg. 它从本地文件夹中获取m2crypto,而不是找到鸡蛋。

This happens to me occasionally when installing python modules. 安装python模块时偶尔会发生这种情况。 There are a couple of things I do to resolve this issue: 我有几件事要解决这个问题:

  1. Sometimes it's because you never set your PYTHONPATH. 有时这是因为你从未设置过你的PYTHONPATH。 Try: 尝试:

    setenv PYTHONPATH /usr/lib/python2.4/site-packages:$PYTHONPATH setenv PYTHONPATH /usr/lib/python2.4/site-packages:$PYTHONPATH

  2. Sometimes it's because of shared libraries found in /usr/lib and you would have to perform: 有时这是因为在/ usr / lib中找到了共享库,你必须执行:

setenv LD_LIBRARY_PATH /usr/lib:$LD_LIBRARY_PATH setenv LD_LIBRARY_PATH / usr / lib:$ LD_LIBRARY_PATH

Let me know how this goes for you. 让我知道这对你有何影响。 Most of the time its just because you didn't set the python path correctly. 大部分时间它只是因为你没有正确设置python路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM