#this has to be the first non-non standard importt ImportError: No module named lib.utils

No module named OpenSSL.crypto and ImportError: SignedJwtAssertionCredentials [没有模块命名openssl.crypto和输入错误:signedjwtassertioncredentials] - 问题-字节技术
No module named OpenSSL.crypto and ImportError: SignedJwtAssertionCredentials
没有模块命名openssl.crypto和输入错误:signedjwtassertioncredentials
问题 (Question)
I am trying to connect to the BigQuery API locally with my local dev_appserver, following this tutorial:
Running the code mentioned on this site, returns an ImportError:
ImportError: cannot import name SignedJwtAssertionCredentials
So I followed the error and spotted (in oauth2client/client.py):
if HAS_CRYPTO:
# PyOpenSSL and PyCrypto are not prerequisites for oauth2client, so if it is
# missing then don't create the SignedJwtAssertionCredentials or the
# verify_id_token() method.
class SignedJwtAssertionCredentials(AssertionCredentials):
But I need "SignedJwtAssertionCredentials"! So I isolated the error further and found (in oauth2client/crypt.py) that this line is actually causing this issue:
from OpenSSL import crypto
&&& import OpenSSL
&&& OpenSSL.__file__
'/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.pyc'
&&& from OpenSSL import crypto
&&& crypto.__file__
'/usr/local/lib/python2.7/site-packages/OpenSSL/crypto.so'
which looks promising and also checked the sys.path of my code:
['/Users/mattes/Developer/gae-projects/project123',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/protorpc-1.0',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webob-1.1.1',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/yaml-3.10']
Anyway, neither adding "/usr/local/lib/python2.7/site-packages/OpenSSL" to the sys.path nor symlinking /usr/local/lib/python2.7/site-packages/OpenSSL under /Users/mattes/Developer/gae-projects/project123 fixes this issue.
/usr/local/lib/python2.7/site-packages/OpenSSL looks like:
├── SSL.so
├── __init__.py
├── __init__.pyc
├── crypto.so
├── rand.so
├── test
├── __init__.py
├── __init__.pyc
├── test_crypto.py
├── test_crypto.pyc
├── test_rand.py
├── test_rand.pyc
├── test_ssl.py
├── test_ssl.pyc
├── util.py
└── util.pyc
├── tsafe.py
├── tsafe.pyc
├── version.py
└── version.pyc
using Mac 10.9 Mavericks, Python 2.7.5
Can somebody help?
我试图连接到bigquery API局部与我的地方dev_appserver,下面这个教程:本网站上所运行的代码,则返回一个ImportError异常:ImportError: cannot import name SignedJwtAssertionCredentials
于是我就跟着错误发现(在oauth2client /客户。PY):if HAS_CRYPTO:
# PyOpenSSL and PyCrypto are not prerequisites for oauth2client, so if it is
# missing then don't create the SignedJwtAssertionCredentials or the
# verify_id_token() method.
class SignedJwtAssertionCredentials(AssertionCredentials):
但我需要“signedjwtassertioncredentials”!所以我分离误差进一步发现(在oauth2client /隐窝。PY)这条线实际上是造成这一问题:from OpenSSL import crypto
我试过了:$ python
&&& import OpenSSL
&&& OpenSSL.__file__
'/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.pyc'
&&& from OpenSSL import crypto
&&& crypto.__file__
'/usr/local/lib/python2.7/site-packages/OpenSSL/crypto.so'
这看起来有前途,还检查了我的代码的目录:['/Users/mattes/Developer/gae-projects/project123',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/protorpc-1.0',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webob-1.1.1',
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/yaml-3.10']
无论如何,不加"/usr/local/lib/python2.7/site-packages/OpenSSL"到sys.path也不symlinking/usr/local/lib/python2.7/site-packages/OpenSSL下/Users/mattes/Developer/gae-projects/project123修复这个问题。/usr/local/lib/python2.7/site-packages/OpenSSL看起来像:├── SSL.so
├── __init__.py
├── __init__.pyc
├── crypto.so
├── rand.so
├── test
├── __init__.py
├── __init__.pyc
├── test_crypto.py
├── test_crypto.pyc
├── test_rand.py
├── test_rand.pyc
├── test_ssl.py
├── test_ssl.pyc
├── util.py
└── util.pyc
├── tsafe.py
├── tsafe.pyc
├── version.py
└── version.pyc
使用MAC 10.9小牛,Python 2.7.5有人能帮忙吗?
最佳答案 (Best Answer)
Fixed the issue by adding pycrypto to libraries section in my app.yaml:
libraries:
- name: pycrypto
version: "latest"
固定的问题,通过添加pycrypto对libraries部分的我app.yaml:libraries:
- name: pycrypto
version: "latest"
答案 (Answer) 2
To get this running on the GAE servers I found that three steps were necessary:
Install the up-to-date version of the
(or at least the oauth2client module).
Note that they provide a GAE targetted download.
Convert my .p12 key file to a .pem format (using the openssl command line tools)
openssl pkcs12
-nocerts -in cert.p12 -out cert.pem
Add the PyCrypto library to the app.yaml.
libraries:
- name: pycrypto
version: "2.6"
# this could be "latest" if you are daring
For dev_appserver it was also necessary to install the PyCrypto library locally, as it is not contained in the SDK.
(OpenSSL is also supported by the API Client library, but I assume that using PyCrypto stays closer to the runtime environment.)
得到这个运行在我发现三的游戏服务器的步骤是必要的:安装最新版本的(或至少oauth2client模块)。值得注意的是,他们提供了一个GAE将下载。将我的关键。P12 PEM格式的文件到一个。(使用OpenSSL命令行工具)openssl pkcs12
-nocerts -in cert.p12 -out cert.pem
在app.yaml中添加pyCrypto图书馆。libraries:
- name: pycrypto
version: "2.6"
# this could be "latest" if you are daring
为dev_appserver也必须安装在本地pyCrypto图书馆,因为它不包含在SDK。(OpenSSL也由API客户端库,支持,但我认为使用pyCrypto保持接近的运行时环境。)
本文翻译自StackoverFlow,英语好的童鞋可直接参考原文:Python (Windows) - ImportError: No module named site - Stack Overflow
to customize your list.
Announcing Stack Overflow Documentation
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
I am trying to install Python for the first time. I downloaded the following installer from the Python website:
. I then ran the installer, selected 'All Users' and all was fine. I installed Python into the default location:
C:\Python27
Next, to test that Python was installed correctly, I navigated to my Python Directory, and ran the "python" command in the windows cmd prompt. It returns me the following error:
ImportError: No module named site
When I do 'python -v' I get the following:
#installing zipimport hook
import zipimport # builtin
#installed zipimport hook
#ImportError: No module named site
#clear builtin._
#clear sys.path
#clear sys.argv
#clear sys.ps1
#clear sys.ps2
#clear sys.exitfunc
#clear sys.exc_type
#clear sys.exc_value
#clear sys.exc_traceback
#clear sys.last_type
#clear sys.last_value
#clear sys.last_traceback
#clear sys.path_hooks
#clear sys.path_importer_cache
#clear sys.meta_path
#clear sys.flags
#clear sys.float_info
#restore sys.stdin
#restore sys.stdout
#restore sys.stderr
#cleanup main
#cleanup[1] zipimport
#cleanup[1] signal
#cleanup[1] exceptions
#cleanup[1] _warnings
#cleanup sys
#cleanup builtin
#cleanup ints: 6 unfreed ints
#cleanup floats
When I do dir C:\Python27\Lib\site.py* I get the following:
C:\Users\Mimminito>dir C:\Python27\Lib\site.py*
Volume in drive C has no label.
Volume Serial Number is DAB9-A863
Directory of C:\Python27\Lib
20,389 bytes
694,910,976 bytes free
Any ideas?
1,47721122
Hey, I've been looking into this problem for myself for almost a day and finally had a breakthrough. Try this:
Setting the PYTHONPATH / PYTHONHOME variables
Right click the Computer icon in the start menu, go to properties.
On the left tab, go to Advanced system settings. In the window that comes up, go to the Advanced tab, then at the bottom click Environment Variables. Click in the list of user variables and start typing Python, and repeat for System variables, just to make certain that you don't have mis-set variables for PYTHONPATH or PYTHONHOME. Next, add new variables (I did in System rather than User, although it may work for User too): PYTHONPATH, set to C:\Python27\Lib. PYTHONHOME, set to C:\Python27.
Hope this helps!
Quick solution: set PYTHONHOME and PYTHONPATH and include PYTHONHOME on PATH
For example if you installed to c:\Python27
set PYTHONHOME=c:\Python27
set PYTHONPATH=c:\Python27\Lib
set PATH=%PYTHONHOME%;%PATH%
Make sure you don't have a trailing '\' on the PYTHON* vars, this seems to break it aswel.
I was having this issue after installing both Windows Python and Cygwin Python, and trying to run Cygwin Python from Cygwin. I solved it by exporting PYTHONHOME=/usr/ and PYTHONPATH=/usr/lib/python2.7
Make sure your PYTHONHOME environment variable is set correctly. You will receive this error if PYTHONHOME is pointing to invalid location or to another Python installation you are trying to run.
C:\&set PYTHONHOME=C:\Python27
C:\&python
Are you trying to run Windows Python from Cygwin? I'm having the same problem. Python in Cygwin fails to import site. Python in Cmd works.
It looks like you need to make sure you run PYTHONHOME and PYTHONPATH through cygwin -aw to make them Windows paths. Also, python seems to be using some incorrect paths.
I think I'll need to install python through cygwin to get it working.
5,89113260
For Windows 10 (follow up on @slckin answer), this can be set through the command line with:
setx PYTHONHOME "C:\Python27"
setx PYTHONPATH "C:\Python27\Lib"
setx PATH "%PYTHONHOME%;%PATH%"
For me it happened because I had 2 versions of python installed - python 27 and python 3.3. Both these folder had path variable set, and hence there was this issue. To fix, this, I moved python27 to temp folder, as I was ok with python 3.3. So do check environment variables like PATH,PYTHONHOME as it may be a issue. Thanks.
1,36621429
You may try the
which is a well done Python installer for Windows.
You just have to desinstall your version and install it...
1,55132449
If somebody will find that it's still not working under non-admin users:
Example error:
ImportError: No module named iso8601
you need to set '--always-unzip' option for easy_install:
easy_install --always-unzip python-keystoneclient
It will unzip your egg files and will allow import to find em.
I up voted slckin's answer.
My problem was that I was thoughtful and added double quotes around the paths.
I removed the double quotes in all of the three variables: PYTHONHOME, PYTHONPATH, and PATH. Note that this was in a cmd or bat file to setup the environment for other tools.
However, the double quotes may be useful in an icon setting.
revealed that the quotes where in the path and not dropped as expected.
I also shorted the PATH so that it was less than 256 characters long.
I went through the same issue of ImportError: No module named site while installing python 2.7.11
Initially I had Python2.5 and the PYTHONHOME path was set to Python2.5.
I renamed it to C:\Python27\ and it resolved the problem.
I have an application which relies heavily on Python and have kept up-to-date with python 2.7.x as new versions are released. Everthing has been fine until 2.7.11 when I got the same "No module named site" error. I've set PYTHONHOME to c:\Python27 and it's working. But the mystery remains why this is now needed when it wasn't with previous releases. And, if it is needed, why doesn't the installer set this var?
I had the same problem. My solution was to repair the Python installation. (It was a new installation so I did not expect a problem but now it is solved.)
To repair (Windows 7):
go to Control Panel -> Programs -> Programs and Features
click on the Python version installed and then press Uninstall/Change.
follow the instructions to repair the installation.
1,82822144
Locate site.py and add its path in PYTHONPATH. This will solve your problem.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledHello,I've written a small pyqt4 code, which on running on an ubuntu 6.10system gives me the foll error:$ python2.4 updLbl.pyTraceback (most recent call last):File "updLbl.py", line 1, in ?import PyQt4.Qt as qtFile "/usr/lib/python2.4/site-packages/PyQt4/Qt.py", line 4, in ?from PyQt4.QtOpenGL import *ImportError: No module named QtOpenGLI've tried installing python-opengl, and also qt4-dev-tools, but theerror persists.What pkg do i need to install to get rid of the error message?Thanks!--warm regards,Pradnyesh Sawant--Be yourself, everyone else is taken. --Anon
Raw Message
Hello,I've written a small pyqt4 code, which on running on an ubuntu 6.10$ python2.4 updLbl.pyFile "updLbl.py", line 1, in ?import PyQt4.Qt as qtThis is wrong, you don't want to do that. You want to do eitherimport PyQt4orfrom PyQt4 import QtCore,QtGuiFile "/usr/lib/python2.4/site-packages/PyQt4/Qt.py", line 4, in ?from PyQt4.QtOpenGL import *ImportError: No module named QtOpenGLI've tried installing python-opengl, and also qt4-dev-tools, but theerror persists.What pkg do i need to install to get rid of the error message?Install apt-file package and do apt-file update. Afterwards you cansearch for files in packages usingapt-file search &filename&If you still get the error when not import the Qt but the QtCore andQtGui packages then you found a bug in Kubuntu's pyqt4 packages. But Ithink you won't get that error.Last but not least, the OpenGL part of PyQt4 is in the packagepython-qt4-gl.Andreas--You are wise, witty, and wonderful, but you spend too much time readingthis sort of trash.
Raw Message
Hello,I've written a small pyqt4 code, which on running on an ubuntu 6.10$ python2.4 updLbl.pyFile "updLbl.py", line 1, in ?import PyQt4.Qt as qtThis is wrong, you don't want to do that.That is not wrong. It just forces him to have all the packages installed and itis never wrong if he builds PyQt4 himself because Qt.py would only try to importthe modules he built.In his current situation he could even comment the"from PyQt4.QtOpenGL import *"line of Qt.py if he does not intend to use OpenGL.By other hand I find pretty convenient not to have to care about if a module ora constant comes from QtCore or from QtGui, specially if I am porting PyQt3 codeto PyQt4 because minimizes changes. I guess that was one of the main motivationsto have Qt.py as part of the standard installation. Afterwards it is just aquestion of taste :)Regards,Armando-------------------------------------------------This mail sent through IMP: http://horde.org/imp/
Raw Message
Hello,I've written a small pyqt4 code, which on running on an ubuntu 6.10$ python2.4 updLbl.pyFile "updLbl.py", line 1, in ?import PyQt4.Qt as qtThis is wrong, you don't want to do that.That is not wrong. It just forces him to have all the packages installed and itis never wrong if he builds PyQt4 himself because Qt.py would only try to importthe modules he built.If it forces him to install all pyqt4 packages, even the ones he doesn'twant to use then using this import is wrong.In his current situation he could even comment the"from PyQt4.QtOpenGL import *"line of Qt.py if he does not intend to use OpenGL.Which means changing a system file which is a bad thing to do. Othersoftware may rightfully rely on having that line there and he has to dothat change every time he updates his PyQt4 packages.By other hand I find pretty convenient not to have to care about if a module ora constant comes from QtCore or from QtGui, specially if I am porting PyQt3 codeto PyQt4 because minimizes changes. I guess that was one of the main motivationsto have Qt.py as part of the standard installation. Afterwards it is just aquestion of taste :)Right, the motivation for the Qt.py package is simply convenience forporting PyQt3 code. Which doesn't mean you should use it in new PyQt4programs. Using something like this creates enough convience whilepreserving a clean global namespace:from PyQt4 import QtCore,QtGuifrom PyQt4.QtGui import QWidget, QPushButton &other classes you use very often&Andreas--Are you sure the back door is locked?
Raw Message
Hello,I've written a small pyqt4 code, which on running on an ubuntu 6.10$ python2.4 updLbl.pyFile "updLbl.py", line 1, in ?import PyQt4.Qt as qtThis is wrong, you don't want to do that.That is not wrong. It just forces him to have all the packages installedand it is never wrong if he builds PyQt4 himself because Qt.py would onlytry to import the modules he built.If it forces him to install all pyqt4 packages, even the ones he doesn'twant to use then using this import is wrong.No, it's a question of choice.In his current situation he could even comment the"from PyQt4.QtOpenGL import *"line of Qt.py if he does not intend to use OpenGL.Which means changing a system file which is a bad thing to do. Othersoftware may rightfully rely on having that line there and he has to dothat change every time he updates his PyQt4 packages.By other hand I find pretty convenient not to have to care about if amodule or a constant comes from QtCore or from QtGui, specially if I amporting PyQt3 code to PyQt4 because minimizes changes. I guess that wasone of the main motivations to have Qt.py as part of the standardinstallation. Afterwards it is just a question of taste :)Right, the motivation for the Qt.py package is simply convenience forporting PyQt3 code. Which doesn't mean you should use it in new PyQt4programs. Using something like this creates enough convience whileThe motivation for the Qt package is to give the developer the choice ofdifferent styles. As the documentation says, it's a matter of personal tasteand neither right nor wrong.from PyQt4 import QtCore,QtGuifrom PyQt4.QtGui import QWidget, QPushButton &other classes you use very often&AndreasPhil
Raw Message
Hello,I've written a small pyqt4 code, which on running on an ubuntu 6.10$ python2.4 updLbl.pyFile "updLbl.py", line 1, in ?import PyQt4.Qt as qtThis is wrong, you don't want to do that.That is not wrong. It just forces him to have all the packages installedand it is never wrong if he builds PyQt4 himself because Qt.py would onlytry to import the modules he built.If it forces him to install all pyqt4 packages, even the ones he doesn'twant to use then using this import is wrong.No, it's a question of choice.I disagree, but not that PyQt4 provides this package. I think its wrongthat distributions ship Qt.py without a dependecy on all python-qt4packages they provide.Andreas--You will be run over by a bus.
Raw Message
Right, the motivation for the Qt.py package is simply convenience forporting PyQt3 code. Which doesn't mean you should use it in new PyQt4programs. Using something like this creates enough convience whilefrom PyQt4 import QtCore,QtGuifrom PyQt4.QtGui import QWidget, QPushButton &other classes you use very often&I strongly disagree.Your suggestion creates gigantic import lines for absolutely no gain. It alsoencourages inconsistency in the source code base (where some classes have aQtNamespace prefix, and others don't) which is even WORSE and more confusingthan the problem you're trying to solve (which is actually a non-problem, asI'm going to try to explain).The clean namespace is preserved by the implicit namespace that Trolltech uses(the 'Q' prefix in front of everything). If you call "QSomething" a class notrealated to Qt in your Qt program, you should be shot in a front anyway byyour reviewer.Which means that there is absolutely no need to clutter all your source codebase with all those "QtCore." "QtGui." in front of everything. I have *never*been confused while reading a PyQt3 source code (that used the star-import); Ihave never found myself thinking "oh damn, this QSomething here! I thought itwas Qt-realted but it is actually something else! They could have used anexplicit "qt." namespace instead!".Being blind about this and thinking that "star-imports are bad no matter what"is just shooting oneself in the foot. The "star-import is bad" coding-standardrule shouldn't be taken literally (like any other coding-standard rule); ifyou understand what it really *means*, you also understand that it's notneeded for PyQt.As Phil said, it's a matter of taste in the end. But surely, I know I'm using"from PyQt4.Qt import *" in all my new programs, and I know other people whodo that as well.--Giovanni Bajo
Raw Message
Right, the motivation for the Qt.py package is simply convenience forporting PyQt3 code. Which doesn't mean you should use it in new PyQt4programs. Using something like this creates enough convience whilefrom PyQt4 import QtCore,QtGuifrom PyQt4.QtGui import QWidget, QPushButton &other classes you use very often&I strongly disagree.Your suggestion creates gigantic import lines for absolutely no gain. Italso encourages inconsistency in the source code base (where some classeshave a QtNamespace prefix, and others don't) which is even WORSE and moreconfusing than the problem you're trying to solve (which is actually anon-problem, as I'm going to try to explain).The clean namespace is preserved by the implicit namespace that Trolltechuses (the 'Q' prefix in front of everything). If you call "QSomething" aclass not realated to Qt in your Qt program, you should be shot in a frontanyway by your reviewer.Which means that there is absolutely no need to clutter all your sourcecode base with all those "QtCore." "QtGui." in front of everything. I have*never* been confused while reading a PyQt3 source code (that used thestar-import); I have never found myself thinking "oh damn, this QSomethinghere! I thought it was Qt-realted but it is actually something else! Theycould have used an explicit "qt." namespace instead!".Being blind about this and thinking that "star-imports are bad no matterwhat" is just shooting oneself in the foot. The "star-import is bad"coding-standard rule shouldn't be taken literally (like any othercoding-standard rule); if you understand what it really *means*, you alsounderstand that it's not needed for PyQt.As Phil said, it's a matter of taste in the end. But surely, I know I'musing "from PyQt4.Qt import *" in all my new programs, and I know otherpeople who do that as well.Personally, I prefer:from PyQt4.QtCore import *from PyQt4.QtGui import *# etcwhich still allows me to use QWidget etc unqualified, but at leastreminds me which of the 10 libraries I'm using.But I agree with the general point that using "import *" is reasonablewhen you have a large library like PyQt4---providing that library hassensible export behaviour. For example, I _assume_ that the PyQt4libraries will only export things with names matching /Q[A-Z]\w+/ andwould expect anything that didn't have such a name either not to beexported or to have a special prefix such as "qt" to avoid unpleasantsurprises.--Mark Summerfield, Qtrac Ltd., www.qtrac.eu
Raw Message
But I agree with the general point that using "import *" is reasonablewhen you have a large library like PyQt4---providing that library hassensible export behaviour. For example, I _assume_ that the PyQt4libraries will only export things with names matching /Q[A-Z]\w+/ andwould expect anything that didn't have such a name either not to beexported or to have a special prefix such as "qt" to avoid unpleasantsurprises.Well, I had always assumed this as well, but it looks like we were both wrong:) The QTextStream non member functions(/4.2/qtextstream.html#related-non-members) are notqualified in any way, and, worse, there are two named "hex" and "oct".Anyway, not that I care specifically: I'm going to prod the trolls about thisissue (it's really unconvenient in C++ as well).--Giovanni Bajo
Raw Message
But I agree with the general point that using "import *" is reasonablewhen you have a large library like PyQt4---providing that library hassensible export behaviour. For example, I _assume_ that the PyQt4libraries will only export things with names matching /Q[A-Z]\w+/ andwould expect anything that didn't have such a name either not to beexported or to have a special prefix such as "qt" to avoid unpleasantsurprises.Well, I had always assumed this as well, but it looks like we were both wrong:) The QTextStream non member functions(/4.2/qtextstream.html#related-non-members) are notqualified in any way, and, worse, there are two named "hex" and "oct".Anyway, not that I care specifically: I'm going to prod the trolls aboutthis issue (it's really unconvenient in C++ as well).&prodded troll&Well, the main dislike about the "consolidated" module for me is that unlessit contains all pyqt4 modules it can never be clear which ones are reallypresent on a given box. It will depend on packaging (by 3rd parties), or evenworse packaging or source building by 3rd parties where the modules are splitup or are build-time settings. So it will be a very unportable thing to use.For that reason alone its use should be discouraged. Namespace clashes aresecond to that IMHO.Needless to say that my py-qt4-* ports for FreeBSD (yes, split up) don'tprovide the consolidated module. Once you split the modules into seperatepackages, managing a consolidated module is a package-list nightmare. It canbe touched/changed by any of the py-qt4-* packages that are installed orupdated afterwards. Another reason to not use the metamodule :)&/prodded troll&IMHO,Dan
Raw Message
But I agree with the general point that using "import *" is reasonablewhen you have a large library like PyQt4---providing that library hassensible export behaviour. For example, I _assume_ that the PyQt4libraries will only export things with names matching /Q[A-Z]\w+/ andwould expect anything that didn't have such a name either not to beexported or to have a special prefix such as "qt" to avoid unpleasantsurprises.Well, I had always assumed this as well, but it looks like we were both wrong:) The QTextStream non member functions(/4.2/qtextstream.html#related-non-members) arenot qualified in any way, and, worse, there are two named "hex" and"oct".Anyway, not that I care specifically: I'm going to prod the trolls aboutthis issue (it's really unconvenient in C++ as well).&prodded troll&Well, the main dislike about the "consolidated" module for me is thatunless it contains all pyqt4 modules it can never be clear which ones arereally present on a given box. It will depend on packaging (by 3rdparties), or even worse packaging or source building by 3rd parties wherethe modules are split up or are build-time settings. So it will be a veryunportable thing to use. For that reason alone its use should bediscouraged. Namespace clashes are second to that IMHO.Needless to say that my py-qt4-* ports for FreeBSD (yes, split up) don'tprovide the consolidated module. Once you split the modules into seperatepackages, managing a consolidated module is a package-list nightmare. Itcan be touched/changed by any of the py-qt4-* packages that are installedor updated afterwards. Another reason to not use the metamodule :)&/prodded troll&IMHO,Then, IMHO, your package is broken. The consolidated module is a documentedcomponent of PyQt and should be present and importing it should always work.However, what it actually imports depends on what other modules areinstalled.It's not as if it is difficult to fix. Just modify Qt.py to import theoptional groups of classes in a try/except.Phil
Raw Message
But I agree with the general point that using "import *" isreasonable when you have a large library like PyQt4---providing thatlibrary has sensible export behaviour. For example, I _assume_ thatthe PyQt4 libraries will only export things with names matching/Q[A-Z]\w+/ and would expect anything that didn't have such a nameeither not to be exported or to have a special prefix such as "qt" toavoid unpleasant surprises.Well, I had always assumed this as well, but it looks like we were both wrong:) The QTextStream non member functions(/4.2/qtextstream.html#related-non-members) arenot qualified in any way, and, worse, there are two named "hex" and"oct".Anyway, not that I care specifically: I'm going to prod the trollsabout this issue (it's really unconvenient in C++ as well).&prodded troll&Well, the main dislike about the "consolidated" module for me is thatunless it contains all pyqt4 modules it can never be clear which ones arereally present on a given box. It will depend on packaging (by 3rdparties), or even worse packaging or source building by 3rd parties wherethe modules are split up or are build-time settings. So it will be a veryunportable thing to use. For that reason alone its use should bediscouraged. Namespace clashes are second to that IMHO.Needless to say that my py-qt4-* ports for FreeBSD (yes, split up) don'tprovide the consolidated module. Once you split the modules into seperatepackages, managing a consolidated module is a package-list nightmare. Itcan be touched/changed by any of the py-qt4-* packages that are installedor updated afterwards. Another reason to not use the metamodule :)&/prodded troll&IMHO,Then, IMHO, your package is broken. The consolidated module is a documentedcomponent of PyQt and should be present and importing it should alwayswork. However, what it actually imports depends on what other modules areinstalled.That's true, but it's also trivial to make one post-install.It's not as if it is difficult to fix. Just modify Qt.py to import theoptional groups of classes in a try/except.And then build/install it immediately with py-qt4-core. Yes, that's possible.I will add this to the port. I admit not having given this much thought,usually I try to patch as little as possible, but the way you put it, I agreethat it should just be changed to expected behaviour.Thanks,Dan
Loading...

我要回帖

更多关于 no module named lxml 的文章

 

随机推荐