PySide导入对比:导入错误:找不到模块“PySide”

2024-06-02 06:44:27 发布

您现在位置:Python中文网/ 问答频道 /正文

当我键入:

username:~/Desktop/folder$ python
Python 2.7.10 |Anaconda 2.3.0 (x86_64)| (default, May 28 2015, 17:04:42) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import PySide

PySide被成功导入(因为我已经在brew install pyside之前做过)。换句话说,导入PySide时不会产生错误。但是,当我尝试运行依赖于PySide的GUI时(通过双击它),我得到:

^{pr2}$

我觉得这与我的Python路径有关(最上面的路径来自Anaconda),而PySide安装在这里:/usr/local/Cellar。在

如何在启动可执行文件时删除ImportError: No module named 'PySide'?在

编辑:

以下是用于编译GUI的cx_Freeze设置文件:

# A simple setup script to create an executable using PyQt4. This also
# demonstrates the method for creating a Windows executable that does not have
# an associated console.
#
# PyQt4app.py is a very simple type of PyQt4 application
#
# Run the build process by running the command 'python setup.py build'
#
# If everything works well you should find a subdirectory in the build
# subdirectory that contains the files needed to run the application

application_title = "MY_GUI" #what you want to application to be called
main_python_file = "GUI.py" #the name of the python file you use to run the program

import sys

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

includes = ["atexit","re"]

setup(
        name = application_title,
        version = "0.1",
        description = "Sample cx_Freeze PyQt4 script",
        options = {"build_exe" : {"includes" : includes }},
        executables = [Executable(main_python_file, base = base)]) 

Tags: thetopyimportbuildyoubaseapplication