sys*_*out 59 python virtualenv pyqt4 pyside
我使用VIRTUALENV与我的发展环境与利润web.py
,simplejson
以及其他面向Web的包.
我将使用Qt开发一个简单的python客户端来重用一些用web.py开发的Api.
这里有人用Virtualenv成功安装了PyQt4吗?
可能吗?
我已经下载了所有二进制文件并已PyQt4
在我的python2.6目录中全局安装.
如果我不使用--no-site--packages
选项,Virtualenv正确地包含PyQt4
在我的新沙箱中,但显然,包含我不需要的所有全局包.
有没有一种干净的方法来准备一个新的沙盒--no-site--packages
选项,然后添加PyQt4
或PySide
使用pip
,easy_install
或其他一些魔术?
Aar*_*lla 52
它应该足以创建一个空的virtualenv,然后将.../site-packages/PyQt4
目录的内容复制到其中.
我建议全局安装一次PyQt4,制作目录的副本,卸载它然后使用这个技巧来创建VE.
Jos*_*uis 46
我也有同样的问题.我使用virtualenvwrapper,所以我编写了这个脚本来在每个新的虚拟环境中创建一个指向PyQt的链接.也许对其他人有用:
#!/bin/bash
# This hook is run after a new virtualenv is activated.
# ~/.virtualenvs/postmkvirtualenv
LIBS=( PyQt4 sip.so )
PYTHON_VERSION=python$(python -c "import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))")
VAR=( $(which -a $PYTHON_VERSION) )
GET_PYTHON_LIB_CMD="from distutils.sysconfig import get_python_lib; print (get_python_lib())"
LIB_VIRTUALENV_PATH=$(python -c "$GET_PYTHON_LIB_CMD")
LIB_SYSTEM_PATH=$(${VAR[-1]} -c "$GET_PYTHON_LIB_CMD")
for LIB in ${LIBS[@]}
do
ln -s $LIB_SYSTEM_PATH/$LIB $LIB_VIRTUALENV_PATH/$LIB
done
Run Code Online (Sandbox Code Playgroud)
Sim*_*nas 28
Linux debian,python 2.7:
sudo apt-get install python-qt4
ln -s /usr/lib/python2.7/dist-packages/PyQt4/ ~/.virtualenvs/myEnv/lib/python2.7/site-packages/
ln -s /usr/lib/python2.7/dist-packages/sip.so ~/.virtualenvs/myEnv/lib/python2.7/site-packages/
对于那些想在Python 3 virtualenv(在OSX上)使用PyQt4的人,首先安装PyQt4和SIP(我将使用自制软件)
$ brew install python3
$ brew install sip --with-python3
$ brew install pyqt --with-python3
Run Code Online (Sandbox Code Playgroud)
然后创建您的虚拟环境
$ virtualenv ...
Run Code Online (Sandbox Code Playgroud)
最后是符号链接(为您机器上安装的版本更改SIP,PyQt4和Python的版本)
$ ln -s /usr/local/Cellar/sip/4.15.5/lib/python3.4/site-packages/*.* ~/{VIRTUALENVHOME}/{VIRTUALENVNAME}/lib/python3.4/site-packages/
$ ln -s /usr/local/Cellar/pyqt/4.10.4/lib/python3.4/site-packages/PyQt4/*.* ~/{VIRTUALENVHOME}/{VIRTUALENVNAME}/lib/python3.4/site-packages/PyQt4
Run Code Online (Sandbox Code Playgroud)
我问是否可以在irc.freenode.net #pyside频道的virtualenv中安装PySide并得到hugopl的肯定回答.所以我按照PySide Binaries for Microsoft Windows的说明进行操作.输出如下.
Z:\virtualenv\pyside>Scripts\activate.bat
(pyside) Z:\virtualenv\pyside>where python
Z:\virtualenv\pyside\Scripts\python.exe
(pyside) Z:\virtualenv\pyside>easy_install PySide
install_dir Z:\virtualenv\pyside\Lib\site-packages\
Searching for PySide
Reading http://pypi.python.org/simple/PySide/
Reading http://www.pyside.org
Reading http://www.pyside.org/files/pkg/
Best match: PySide 1.0.0beta1qt471
Downloading http://www.pyside.org/files/pkg/PySide-1.0.0beta1qt471.win32-py2.6.exe
Processing PySide-1.0.0beta1qt471.win32-py2.6.exe
Deleting c:\users\piotr\appdata\local\temp\easy_install-fvfa7e\PySide-1.0.0beta1qt471-py2.6-win32.egg.tmp\EGG-INFO\scripts\py
ide-uic-script.py
Deleting c:\users\piotr\appdata\local\temp\easy_install-fvfa7e\PySide-1.0.0beta1qt471-py2.6-win32.egg.tmp\EGG-INFO\scripts\py
ide-uic.exe
creating 'c:\users\piotr\appdata\local\temp\easy_install-fvfa7e\PySide-1.0.0beta1qt471-py2.6-win32.egg' and adding 'c:\users\
iotr\appdata\local\temp\easy_install-fvfa7e\PySide-1.0.0beta1qt471-py2.6-win32.egg.tmp' to it
creating z:\virtualenv\pyside\lib\site-packages\PySide-1.0.0beta1qt471-py2.6-win32.egg
Extracting PySide-1.0.0beta1qt471-py2.6-win32.egg to z:\virtualenv\pyside\lib\site-packages
Adding PySide 1.0.0beta1qt471 to easy-install.pth file
Installing pyside-uic-script.pyc script to Z:\virtualenv\pyside\Scripts
Installing pyside_postinstall.py script to Z:\virtualenv\pyside\Scripts
Installing pyside_postinstall.pyc script to Z:\virtualenv\pyside\Scripts
Installing pyside-uic-script.py script to Z:\virtualenv\pyside\Scripts
Installing pyside-uic.exe script to Z:\virtualenv\pyside\Scripts
Installed z:\virtualenv\pyside\lib\site-packages\pyside-1.0.0beta1qt471-py2.6-win32.egg
Processing dependencies for PySide
Finished processing dependencies for PySide
(pyside) Z:\virtualenv\pyside>python Scripts\pyside_postinstall.py -install
Generating file Z:\virtualenv\pyside\Scripts\qt.conf...
The PySide extensions were successfully installed.
Run Code Online (Sandbox Code Playgroud)
让我们假设您的virtualenv名为myProject,并且您正在使用virtualenvwrapper.还假设了一个Unix平台.
$ workon myProject
$ pip install --no-install SIP
$ pip install --no-install PyQt
$ cd ~/.virtualenvs/myProject/build/SIP
$ python configure.py
$ make
$ make install
$ cd ~/.virtualenvs/myProject/build/PyQt
$ python configure.py
$ make
$ make install
$ cd && rm -rf ~/.virtualenvs/myProject/build # Optional.
Run Code Online (Sandbox Code Playgroud)
最简单的方法是安装:vext.pyqt4
这将为PyQt4
您的virtualenv 添加单个系统包.
Ubuntu 16.04用法:
sudo apt install python3-pyqt4
mkvirtualenv --python=python3.5 venv
pip install --no-use-wheel vext.pyqt4
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
37233 次 |
最近记录: |