Linux 的新手:需要一些帮助在 ubuntu 18.04 上安装 wxpython 开发环境

New to Linux: need some help installing wxpython development environment on ubuntu 18.04

我来自 windows 背景,正在 python 2.7.15 和 wxpython 2.8.12.1 下为工作项目制作程序(这是他们的既定配置) .

linux 的学习曲线对我来说很陡峭。我开始尝试在 ubuntu.. 上获得相同的环境,持续了好几个小时。我不愿意承认,在经历了很多挫折之后,我基本上放弃了从源代码编译我的确切版本的尝试。

我现在只想开始使用任何当前推荐配置的 wxpython 进行编程(python 3.7 和 wxpython 4.0 会很好)

我有 Ubuntu 18.04,它带有 python3: 3.6.7。我也有 python 2.7.15。我还通过 sudo apt-get install python3-pip

安装了 python 3.7.2

我在 windows 上使用翼 IDE,所以我想我也会在 Ubuntu 上做同样的事情。我正在努力使它并行进行。

与此同时,我从 Ubuntu 软件商店安装了 PyCharm。它与 wing 有很大不同,并试图让我在项目中使用虚拟环境。我正在努力让它继续下去,但我似乎无法将环境与正确的 python / wxpython 包对齐。即使是简单的代码示例也不会 运行。

好的,有人可以帮我指出实现这一目标的方法吗?我应该使用什么版本?

我应该使用 apt-get 吗?我应该使用 pip 吗?这个安装只是为了好玩,我想编程!

--更新:所以我得到了翼,如果我使用 python3.6 作为环境,我的 "hello world" 测试与 wxpython 工作正常。如果我切换到 3.7,我无法让它工作 ("missing _core") 和其他错误。我想我需要帮助来尝试设置 3.7。尝试使用 pip "python3.7 pip install wxpython" 给出

Error running configure ERROR: failed building wxWidgets Traceback (most recent call last): File "build.py", line 1321, in cmd_build_wx wxbuild.main(wxDir(), build_options) File "/tmp/pip-build-begnss0_/wxpython/buildtools/build_wxwidgets.py", line 375, in main "Error running configure") File "/tmp/pip-build-begnss0_/wxpython/buildtools/build_wxwidgets.py", line 85, in exitIfError raise builder.BuildError(msg) buildtools.builder.BuildError: Error running configure Finished command: build_wx (0m9.551s) Finished command: build (0m9.551s) Command '"/usr/bin/python3.7" -u build.py build' failed with exit code 1.

---------------------------------------- Command "/usr/bin/python3.7 -u -c "import setuptools,

tokenize;file='/tmp/pip-build-begnss0_/wxpython/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-wfsndtdv-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-begnss0_/wxpython/

仅使用 apt-get 来安装 python 和一些基本软件包(如 python-pip 和 python-dev)。您应该使用 virtualenv 安装其他所有内容,但如果您对此不满意 sudo pip 对于玩具项目来说没问题。官方存储库中的包可能很旧。

这是我最后做的,现在可以了:请原谅我的“笨拙”

https://linuxize.com/post/how-to-install-python-3-7-on-ubuntu-18-04/

$sudo apt update
$sudo apt install software-properties-common
$sudo add-apt-repository ppa:deadsnakes/ppa
$sudo apt install python3.7

https://linuxize.com/post/how-to-install-pip-on-ubuntu-18.04/

点为 python 3:

$sudo apt install python3-pip
  

pip for python 2:(并安装 python 2.7.15)

$sudo apt install python-pip

https://wiki.wxpython.org/How%20to%20install%20wxPython

安装python3.7 wxpython凤凰(4.0):

$sudo python3.7 pip install -U \
    -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 \
    wxPython

现在安装IDE(我选择wing):https://wingware.com/download-file&prod=wingper&target=https://wingware.com/pub/wingide-personal/6.1.4/wingide-personal6_6.1.4-1_amd64.deb

感谢您提供有关虚拟环境的提示,我现在明白了!
我所看到的一切都建议创建虚拟环境,如果我开始一个严肃的项目,我会这样做。

这样做并将 wing 的项目设置为 3.7 发行版使用 python 3.7.2 和 wxpython 4.0.4

3.7.2 (default, Dec 25 2018, 03:50:46) 
[GCC 7.3.0]
Python Type "help", "copyright", "credits" or "license" for more information.
import wx
wx.version()
'4.0.4 gtk3 (phoenix) wxWidgets 3.0.5'
import sys
sys.version_info
sys.version_info(major=3, minor=7, micro=2, releaselevel='final', serial=0)

创建虚拟环境的简单方法是 pipenv。

sudo pip install pipenv

mkdir test_project

cd test_project

pipenv install packagename

pipenv shell

这会将您设置在当前目录的虚拟环境中,您应该会在提示符开头的括号中看到目录名称。

我对 python 还是很陌生,但这似乎是虚拟环境的最快方法,是在阅读 Django for beginners 书籍时学到的。