I want to develop with these tools:
MS-Windows 10
Python3
gtk
PyCharm
I installed PyCharm, but up to now Python and gtk are not installed up to now.
Sub questions:
use 32 or 64 Bit version of Python?
How to install gtk for python (pip or exe)?
Use virtual env in PyCharm or use "Existing Interpreter"?
AFAIK you cant install gtk for Python on Windows with pip.
Update
I follow this guide now: https://pygobject.readthedocs.io/en/latest/getting_started.html#windows-getting-started
Update2
gtk on windows seems to be hardly used. There were many strange things, and I use pyside2 (QT) now and I am happy
use 32 or 64 Bit version of Python?
The documentation suggests 32 bit for msys2, so this is the safest. However, if you have a 64 bit computer, the 64 bit version could allow some more processing power for larger tasks.
How to install gtk for python (pip or exe)?
Most definitely using the .exe available from this source. This tool is a package manager for Windows that will let you install gtk and its dependencies. Instructions there will walk you through setting up the default environment, then from that environment run pacman -Suy and pacman -S mingw-w64-i686-gtk3 mingw-w64-i686-python2-gobject mingw-w64-i686-python3-gobject.
Use virtual env in PyCharm or use "Existing Interpreter"?
Using the 'Existing Intepreter' is a must for this method of installation, as you need to point PyCharm to your msys2 Python, which actually has gtk available. It should be located at C:\msys64\bin\python.exe. Keep in mind that you might not be able to run some scripts directly through PyCharm this way, as Python will be running through a virtual bash-like environment. Save your scripts in the C:\msys64\home\<username> directory so that you can run them easily when you open msys2 with python3 script.py.
use 32 or 64 Bit version of Python?
You can pick any, it doesn't really matter.
how to install gtk for python (pip or exe)?
You should able to install it with pip: pip install pygtk.
Use virtual env in PyCharm or use "Existing Interpreter"?
If you don't know, you probably need "Existing interpreter".
There should be an option to select path to your python.exe
It should be there: Menu->File->Settings->Project->Project Interpteter
There two ways of doing what you want.
But first, lets set something straight, when you say gtk, you don't specify GTK-2 or GTK-3. GTK-2 python bindings aka PyGTK is quite an old package (but still possible to use). GTK-3 python bindings, included in PyGobject are, I imagine, what you want.
First option
So, I'll start with the more restrictive one.
You can install PyGObject through the PyGI AllInOne installer. This is a .exe installer that comes with a lot of stuff, from gtk3 and gstreamer, to gnome applications like Glade and Gedit, to non gnome applications. Why do I say it's restrictive? It only works with Python from version 2.7+ to 3.4+ (32 or 64 bits). So if you want to use Python 3.6, you can't use this. And it seems that it will never be updated.
Second option
The other way is using MSYS2, like someone advised before. This option lets you use the current versions of Python supported by mingw-64 repository. Which I believe right now is Python 3.7.
You can install following the steps as described in the PyGObject site. Or the way explained below (CLion).
I don't know how to use PyCharm with a MSYS2 python installation, but a bit of googling led me to this tutorial for CLion. Maybe there's an analog for PyCharm.
update a couple years later, in case someone else is stumbling down this path - pyGTK/pyGObject now only installs via msys2/mwing. This causes problems with several things.
Firstly, the whole msys python is incompatible with the more normal pip way of distributing tools. From what i've seen, most python tools are shared via pip and wheels now. I'm working with a network messaging library (pynng) which is available via source and pip. I really dont want to go thru the rebuild-from-source thing. That is so last century unix mods.
Secondly, when i tried using mwing's python with pyCharm it failed, saying there were various permission errors. mwing seems to like making things restricted. Maybe if i ran pyCharm as admin it might work.
Maybe I will go with the original post's update and ditch GTK for pyside/QT. I'm not really happy with the look/feel of GTK anyway. It was just the simple solution for the rPi project I was doing.
Step 1: Download the Python 3 Installer
Open a browser window and navigate to the Download page for Windows at python.org.
Step 2: Underneath the heading at the top that says Python Releases for Windows,
click on the link for the Python 3.x.x.scroll to the bottom and select either Windows x86-64 executable installer for 64-bit or Windows x86 executable installer for 32-bit.
The difference between 32bit and 64bit:
If your system has a 32-bit processor, then you should choose the 32-bit installer.
On a 64-bit system, either installer will actually work for most purposes. The 32-bit the version will generally use less memory, but the 64-bit version performs better for applications with intensive computation.source
Step 3: For PyCharm installation follow link
Using Existing Interpreter (pre-installed python)
Step 4: Launch PyCharam, go to settings and click on project interpreter, browse path python3 installed in above step 2.
Step 5: how to install PyGTK or any library in PyCharm selected python environment. Follow step 4 and then click on green + sign in search bar just name the library you want to be installed
.
Here onwards you can install any library just follow step 5, instead of doing pip install library-name each time.
You can also use the virtual environment option, the advantage is that some libraries can work only with the specific version of python.so you can set different version of python in different virtual environments on the same machine.
virtualenv really shines when you have a number of projects and don't want them to all share the same Python installation. For example, you could have two projects with conflicting requirements. virtual environment set-up
For the latest version of PyGTK instead of Step 5 follow this link
Related
I'm newbie of python programming.
I have windows 7 laptop and I'm also running virtual box Ubuntu.
I manually installed python3.5 on Win7 through Eclipse first. The default python version in my Virtualbox Ubuntu is 2.7.11.
Is it possible for me to install python packages through my VirtualBox to my Win7 python3.5?
Will it bring any problem with multiple versions of python.
python 3.5 packages do not work with python 2.7 and vice versa.
And I even think that you can't install packages from linux to windows.
I think what you wish to accomplish is to have a same version Python across both machine.
Best way is to go about doing it is to either install Python 2.7.x on Windows 7 or upgrade python 2.7.x on your Ubuntu to Python 3.5.x. Neither is good or bad.
To upgrade your Python 2.7.x to 3.x.x on your ubuntu machine,follow the instructions here.
If you wish to wish to install Python 2.7.x on your Windows,simply download the compatible exe from official page .It will create a folder under c: e.g. C:\Python27 .Thereafter,add the python path to environment variable PATH.
As for installing packages,the command remains the same across both OS.
pip install <package-name>
Usually packages have dedicated versions for different python versions.pip install will automatically resolve versions and install the compatible package version.
The Ubuntu VirtualBox is not just a linux-looking frontend to your existing Win7 install. It's a completely separate OS that runs as if it were on a separate computer. You can set up shared folders to share data between the host and guest, but trying to use Linux to install programs on Windows would be error-prone and risky even if you could do it.
If you plan to be using Python on Windows, you'll need to install the packages on Windows, and a Linux VirtualBox isn't going to help you with that at all. If you're uncomfortable with the Windows command line, read up on some tutorials. There are also some alternative Windows shells that provide some advantages over the built-in CMD.
If you'd rather work on Linux, you can do that, but you'd want to do it entirely inside the VirtualBox. Inside Linux, you could install the version of Python you want, install the packages you want, and use whatever dev tools you want, as if you were working on a Linux computer. (Although in this case I have to wonder why you aren't actually using a Linux computer instead of a Windows one.)
I am currently attempting to install a third-party package (gnuradio, to be specific) into the Canopy version of Python on an Ubuntu computer. I currently have the entire package stored in my filesystem as a folder with subfolders and python files; however, I have been able to find no information as to how to make the transition into a functionally installed and recognized package. How can I do so?
You shouldn't use third party pythons on Ubuntu, unless you very exactly know what you're doing (you don't). Ubuntu keeps your python up-to-date and uses the package manager to install pack
So, setting up a recent version of python is just
sudo apt-get install python
So if you still want to integrate GNU Radio into your canopy installation, you will need to get the development headers of exactly their version of python, and specify that you want to only use them etc, and build GNU Radio from source. I do not recommend doing that.
In my opinion, you should probably rather install GNU Radio either from source against the python and libraries on your main OS rather than canopy's happy little installation folder, or use the gnuradio package that Ubuntu has.
I recommend using pybombs to install GNU Radio from source. You'll get the latest and greatest, in a safe install prefix, and easy access to bleeding edge SDR device drivers.
(1) Python packaging is inconsistent, but in general, it suffices to type python setup.py install from the package's top directory (see https://docs.python.org/2/install/#the-new-standard-distutils)
(2) How to be sure that you are installing into Canopy Python rather than your system Python? See https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-Python-from-the-command-line (tl;dr open a Canopy Terminal window from the Canopy Tools menu.)
EDIT: Marcus Müller has clarified below that gnuradio is not a python package, so this general advice is true but irrelevant. See his answer below.
Question: How to install Pyscripter on Cygwin?
Scenerio: I have installed portable apps on a usb, then installed cygwin portable version 0.9 on it. Under cygwin, I have installed Python 2.6. I am curerntly using it with the idle IDE but I would like to use Pyscripter instead.
I can not use portable python because I need to install additional modules on python such as pyevolve and Cantera. Alternatively, maybe someone could let me know how to add these modules to portable python.
You can create virtualenv in your usb. And just switch it on in any other computer via Cygwin from our usb. It is not a way to install Pyscripter. But it is way for add modules to your portable version of python.
For anyone else trying this, note that PyScripter is intended to run under Windows, not Linux. The steps are: (1) in Windows, install a python distribution from python.org, and (2) in Windows, install PyScripter.
Note, too, that PyScripter has the desired console (interactive python interpreter) window, and a pip-based package manager that allows adding packages. For example, to add Pandas to an app, do the following:
menu: Tools menu
submenu: Tools
menu item: Install packages with pip
Package Name: pandas
The correct pandas package with required dependencies will be installed. (At least, that is what happened in my case). I was then able to import pandas into my app and use it without any problem.
Cygwin is a Linux environment that installs/runs under Windows. One of its main claims to fame is that it allows you to use Linux commands at the Windows CMD prompt. It also allows you to install/run certain Linux apps, which you then run in the Cygwin (and/or Cygwin-X graphical) environment. For example, it is possible to install/run Eric6 (a graphical Linux python IDE) under Cygwin. (I tried that, it worked - but not as great as Pyscripter)
For my money, I found that Pyscripter under Windows works great - and is much, much nicer than Eric6 under Cygwin. I am a Notepad++ user for HTML/js/PHP and started out using Anaconda (Spyder) to code in Python. PyScripter is much closer to NPP than, for e.g., Spyder or IDLE or Eric6 - and is more like what I had hoped to find in the Python world - and it simply runs under Windows like any other Windows app.
References:
https://sourceforge.net/projects/pyscripter
https://github.com/pyscripter/pyscripter
I was wondering if anyone had tips on how to completely remove a python installation form Mac OSX (10.5.8) ... including virtual environments and its related binaries. Over the past few years I've completely messed up the installed site-packages, virtual-environments, etc. and the only way I can see to fix it is to just uninstall everything and re-install.
I'd like to completely re-do everything and use virtualenv, pip, etc. from the beginning.
On the other hand if anyone knows a way to do this without removing python and re-installing I'd be happy to here about it.
Thanks,
Will
Just for everyone else's reference. I found this in the Python documentation here:
Mac OS X 10.5 comes with Python 2.5.1 pre-installed by Apple. If you wish, you are invited to install the
most recent version of Python from the
Python website
(http://www.python.org). A current
“universal binary” build of Python,
which runs natively on the Mac’s new
Intel and legacy PPC CPU’s, is
available there.
What you get after installing is a
number of things:
* A MacPython 2.5 folder in your Applications folder. In here you find
IDLE, the development environment that
is a standard part of official Python
distributions; PythonLauncher, which
handles double-clicking Python scripts
from the Finder; and the “Build
Applet” tool, which allows you to
package Python scripts as standalone
applications on your system.
* A framework /Library/Frameworks/Python.framework,
which includes the Python executable
and libraries. The installer adds this
location to your shell path. To
uninstall MacPython, you can simply
remove these three things. A symlink
to the Python executable is placed in
/usr/local/bin/.
I removed these and the virtualenv directories. Then I re-installed everything and its working fine now.
You should be able to delete the packages you've installed from /Library/Python/2.*/site-packages/. I do not think any package installers will install by default to /System/Library, which should save you from needing to remove Python itself.
That said, you could also use virtualenv with --no-site-packages, and just ignore whatever packages you've installed system-wide without needing to remove them.
I've been using MacPorts Python 2.6 on OS X 10.6.
I am considering also installing the Enthought Python Distribution (EPD) on the same machine because it comes preconfigured with matplotlib and other nice data analysis and visualization packages.
Can the two Python distributions co-exist peacefully on the same machine?
What potential problems will I have to look out for (e.g., environment variables)?
I know that building matplotlib through MacPorts is an option, but the process is lengthy (on the order of a full day) and there are open questions about compiling some dependencies on 64bit Intel.
I would like to know about the tradeoffs before committing to one of the two approaches.
I'm not an OSX user, so I can't say for certain, but you should be fine.
EPD bundles its own python interpreter and all required libraries. The installer basically just extracts a tarball into a stand-alone folder.
The linux installer doesn't modify any environment variables (not even $PATH), so I assume the mac installer is similar.
(Because of this, you'll probably want to manually set up aliases to the EPD python/ipython/etc binaries so you can more easily call them without changing your $PATH.)
EPD really should be completely stand-alone, as far as I know. It should be safe to install along-side anything else.
I've used EPD on Windows 7. It works great. Only stalled on me a couple of times with rather large data set.
I also use OSX, and was about to install EPD but hesitating a bit.
I think python 2.7.3 that comes with EPD (early 2013) will become the default python. Normally, upgrading to 2.7 from 2.6 should not be much of problem based on my personal experience. But I am a bit concerned to have 2 versions of 2.7 and what kind of impact it will have on using GAE SDK on my OSX. (Upgrading created a bit of hassle with GAE SKD.)
Here is what EPD readme says:
A full installation will install the following:
* Python framework -- installed into:
/Library/Frameworks/Python.framework/Versions/7.3
Python applications -- installed into
/Applications/Enthought
System fixes -- makes the EPD Python your default one by adding lines to
your .bash_profile to your path.
I think I will sleep on this.