1.?問題錯誤信息:?
? ?執(zhí)行命令:? ?virtualenv -p /usr/bin/python3.8? ?py3env , 創(chuàng)建py3env的python3.8的虛擬環(huán)境
? ?錯誤信息:
Running virtualenv with interpreter /usr/bin/python3.8
Using base prefix?'/usr/local/python3'
/usr/lib/python3/dist-packages/virtualenv.py:1082: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation?for?alternative uses
??import?imp
New python executable in /home/mi/work/WALL-E/code/walle_new/py3env/bin/python3.8
Also creating executable in /home/mi/work/WALL-E/code/walle_new/py3env/bin/python
Installing setuptools, pkg_resources, pip, wheel...
??Complete output from command /home/mi/work/WALL-E...py3env/bin/python3.8?- setuptools pkg_resources pip wheel:
??Exception:
Traceback (most recent call last):
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/basecommand.py", line?209, in main
????status = self.run(options, args)
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/commands/install.py", line?267, in run
????with self._build_session(options) as session:
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/basecommand.py", line?66, in _build_session
????session = PipSession(
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/download.py", line?321, in __init__
????self.headers["User-Agent"] = user_agent()
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/download.py", line?93, in user_agent
????zip(["name",?"version",?"id"], platform.linux_distribution()),
AttributeError: module?'platform'?has no attribute?'linux_distribution'
Traceback (most recent call last):
??File?"<stdin>", line?24, in <module>
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/__init__.py", line?217, in main
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/basecommand.py", line?242, in main
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/basecommand.py", line?66, in _build_session
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/download.py", line?321, in __init__
??File?"/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/download.py", line?93, in user_agent
AttributeError: module?'platform'?has no attribute?'linux_distribution'
----------------------------------------
...Installing setuptools, pkg_resources, pip, wheel...done.
Traceback (most recent call last):
??File?"/usr/lib/python3/dist-packages/virtualenv.py", line?2363, in <module>
????main()
??File?"/usr/lib/python3/dist-packages/virtualenv.py", line?709, in main
????create_environment(home_dir,
??File?"/usr/lib/python3/dist-packages/virtualenv.py", line?984, in create_environment
????install_wheel(
??File?"/usr/lib/python3/dist-packages/virtualenv.py", line?918, in install_wheel
????call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
??File?"/usr/lib/python3/dist-packages/virtualenv.py", line?810, in call_subprocess
????raise OSError(
OSError: Command /home/mi/work/WALL-E...py3env/bin/python3.8?- setuptools pkg_resources pip wheel failed with error code?1
2.問題解決思路:?
從上面可知缠黍,關鍵信息:AttributeError: module 'platform' has no attribute 'linux_distribution'
原因是:https://blog.csdn.net/qq_42415326/article/details/104767193
python3.7以后platform.linux_distribution()被移除了件相。
(詳見https://docs.python.org/3.5/library/platform.html#platform.linux_distribution)
那安裝wheel卻走到了此方法线欲,想著進入“/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/download.py”酱讶, 修改為“distro.linux_distribution()”唤衫。 無奈是一個pip-8.1.1-py2.py3-none-any.whl是一個文件而非目錄。
?wheel文件是什么铐殃?海洼??
wheel 是新的 Python 的 disribution富腊,用于替代 Python 傳統(tǒng)的 egg 文件坏逢。目前有超過一半的庫文件有對應的 wheel 文件。
*.whl文件有一點與*.egg文件相似:實際上它們都是“偽裝的”*.zip文件赘被。如果你將*.whl文件名擴展改為*.zip是整,你就可以使用你的zip應用程序打開它,并且可以查看它包含的文件和文件夾民假。
那么按上面浮入,應該是系統(tǒng)的wheel文件比較老了,采用的是python3.7之前來實現(xiàn)的羊异,那么應該替換一個新的事秀。
https://www.lfd.uci.edu/~gohlke/pythonlibs/這里有系統(tǒng)的wheel文件彤断,下載一個最新的pip-20.0.2-py2.py3-none-any.whl,更名為系統(tǒng)中的pip-8.1.1-py2.py3-none-any.whl易迹,替換系統(tǒng)的pip-8.1.1-py2.py3-none-any.whl文件宰衙。
?virtualenv -p /usr/bin/python3.8?py3env
Running virtualenv with interpreter /usr/bin/python3.8
Using base prefix?'/usr/local/python3'
/usr/lib/python3/dist-packages/virtualenv.py:1082: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation?for?alternative uses
import?imp
New python executable in /home/mi/work/WALL-E/code/walle_new/py3env/bin/python3.8
Also creating executable in /home/mi/work/WALL-E/code/walle_new/py3env/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
成功了!6糜供炼!