问题
I am trying to run tox tests as python 2.6. I just installed 2.6 and am now getting past the "Interpreter error: no python 2.6" style error, but tox is now crashing at zlib. Zlib is on my machine however. My tox issue looks like:
$ tox -e py26
GLOB sdist-make: /home/cchilders/work_projects/webapi/setup.py
py26 create: /home/cchilders/work_projects/webapi/.tox/py26
ERROR: invocation failed (exit code 1), logfile: /home/cchilders/work_projects/webapi/.tox/py26/log/py26-0.log
ERROR: actionid: py26
msg: getenv
cmdargs: ['/home/cchilders/.virtualenvs/webapi/bin/python', '-m', 'virtualenv', '--python', '/usr/local/bin/python2.6', 'py26']
env: {'MANDATORY_PATH': '/usr/share/gconf/ubuntu.mandatory.path', 'XDG_GREETER_DATA_DIR': '/var/lib/lightdm-data/cchilders', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'PROJECT_HOME': '/home/cchilders/work_projects', 'UPSTART_EVENTS': 'xsession started', 'LESSOPEN': '| /usr/bin/lesspipe %s', 'XDG_SESSION_TYPE': 'x11', 'QT_IM_MODULE': 'ibus', 'LOGNAME': 'cchilders', 'USER': 'cchilders', 'PATH': '/home/cchilders/work_projects/webapi/.tox/py26/bin:/home/cchilders/.virtualenvs/webapi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/bin/virtualenvwrapper.sh', 'XDG_VTNR': '7', 'GNOME_KEYRING_CONTROL': '', 'VIRTUALENVWRAPPER_SCRIPT': '/usr/local/bin/virtualenvwrapper.sh', 'DISPLAY': ':0', 'VIRTUALENVWRAPPER_PROJECT_FILENAME': '.project', 'XDG_SESSION_DESKTOP': 'ubuntu', 'TERM': 'xterm', 'SHELL': '/bin/bash', 'XDG_SESSION_PATH': '/org/freedesktop/DisplayManager/Session0', 'XAUTHORITY': '/home/cchilders/.Xauthority', 'LANGUAGE': 'en_US', 'DEFAULTS_PATH': '/usr/share/gconf/ubuntu.default.path', 'SHLVL': '1', 'QT_QPA_PLATFORMTHEME': 'appmenu-qt5', 'POSTMARK_KEY': 'ba7663a2-19ba-4a42-bf69-5b4485fcab6f', 'TDSDUMP': '/tmp/freetds.log', 'UPSTART_INSTANCE': '', 'COMPIZ_CONFIG_PROFILE': 'ubuntu', 'WINDOWID': '69206027', 'EDITOR': 'nano', 'CLUTTER_IM_MODULE': 'xim', 'IM_CONFIG_PHASE': '1', 'PYTHONHASHSEED': '209016217', 'GPG_AGENT_INFO': '/run/user/1000/keyring/gpg:0:1', 'HOME': '/home/cchilders', 'QT4_IM_MODULE': 'xim', 'LANG': 'en_US.UTF-8', 'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh', 'XDG_RUNTIME_DIR': '/run/user/1000', 'WORKON_HOME': '/home/cchilders/.virtualenvs', 'GTK_IM_MODULE': 'ibus', 'PYTHONPATH': '/home/cchilders/work_projects', 'COMP_WORDBREAKS': ' \t\n"\'><;|&(:', 'SESSIONTYPE': 'gnome-session', 'VIRTUAL_ENV': '/home/cchilders/work_projects/webapi/.tox/py26', 'VTE_VERSION': '3803', 'GDMSESSION': 'ubuntu', 'XMODIFIERS': '@im=ibus', 'UPSTART_JOB': 'unity7', 'VIRTUALENVWRAPPER_WORKON_CD': '1', 'PS1': '\n\\[\\033[0;35m\\](webapi)\\[\\e[0m\\] \\[\\033[0;32m\\]\\u\\[\\e[0m\\]:\\[\\033[1;33m\\]\\w\\[\\e[0m\\]\\[\\e[0;36m\\] (master)\\[\\e[0m\\] \n$ ', 'XDG_DATA_DIRS': '/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/', 'XDG_SEAT_PATH': '/org/freedesktop/DisplayManager/Seat0', 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg', 'XDG_CURRENT_DESKTOP': 'Unity', 'XDG_SESSION_ID': 'c1', 'DBUS_SESSION_BUS_ADDRESS': 'unix:abstract=/tmp/dbus-bmBbueNSW6', '_': '/home/cchilders/.virtualenvs/webapi/bin/tox', 'GNOME_KEYRING_PID': '', 'SESSION': 'ubuntu', 'DESKTOP_SESSION': 'ubuntu', 'UPSTART_SESSION': 'unix:abstract=/com/ubuntu/upstart-session/1000/1300', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'VIRTUALENVWRAPPER_HOOK_DIR': '/home/cchilders/.virtualenvs', 'OLDPWD': '/home/cchilders', 'GDM_LANG': 'en_US', 'GTK_MODULES': 'overlay-scrollbar:unity-gtk-module', 'INSTANCE': '', 'PWD': '/home/cchilders/work_projects/webapi', 'JOB': 'unity-settings-daemon', 'BASH_PROF': '/home/cchilders/.bash_profile', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:', 'COMPIZ_BIN_PATH': '/usr/bin/', 'XDG_SEAT': 'seat0'}
Traceback (most recent call last):
File "/home/cchilders/.virtualenvs/webapi/lib/python2.7/site-packages/virtualenv.py", line 22, in <module>
import zlib
ImportError: No module named zlib
Running virtualenv with interpreter /usr/local/bin/python2.6
ERROR: InvocationError: /home/cchilders/.virtualenvs/webapi/bin/python -m virtualenv --python /usr/local/bin/python2.6 py26 (see /home/cchilders/work_projects/webapi/.tox/py26/log/py26-0.log)
_____________________________________________________________________________________ summary _____________________________________________________________________________________
ERROR: py26: InvocationError: /home/cchilders/.virtualenvs/webapi/bin/python -m virtualenv --python /usr/local/bin/python2.6 py26 (see /home/cchilders/work_projects/webapi/.tox/py26/log/py26-0.log)
I tried upgrading these:
(webapi) cchilders:~/Downloads/Python-2.6.9
$ sudo apt-get install --upgrade zlibc zlib1g zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
zlib1g is already the newest version.
zlib1g-dev is already the newest version.
zlibc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 22 not upgraded.
Python 2.6 is working, but when I installed it I got the warning:
Failed to find the necessary bits to build these modules:
_bsddb _curses _curses_panel
_hashlib _sqlite3 _ssl
_tkinter bsddb185 bz2
dbm dl gdbm
imageop linuxaudiodev ossaudiodev
readline sunaudiodev zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
crypt nis
running build_scripts
Checking setup.py leads to seeing python wants zlib 1.3.3, but I just tried to upgrade so it should be current.
Running tests as 3.4 works:
$ tox -e py34 py34: commands succeeded congratulations :)
What can be the issue here? Is there a way to reinstall python2.6 that won't error on zlib? Thank you
回答1:
Solved by obscure ubuntu problem:
http://joequery.me/guides/python26-no-module-zlib/
回答2:
Checking setup.py leads to seeing python wants zlib 1.3.3, but I just tried to upgrade so it should be current.
This is late, but if anyone else has a similar problem:
It seems that tox
creates the virtualenv only once. If it did that, and you afterwards e.g. altered the requirements.txt
file, you need to re-create it:
To force tox to recreate a (particular) virtual environment:
tox --recreate -e py27
would trigger a complete reinstallation of the existing py27 environment (or create it afresh if it doesn’t exist).
来源:https://stackoverflow.com/questions/37928497/importerror-no-module-named-zlib-tox