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.)
Related
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
I've just installed Anaconda on my macOS machine and it has changed my PATH so that now Python 3.6 is the default version (i.e. the Python 3.6 interpreter opens when I type python in the Terminal). I'm fine with this since this is the version I usually use, but I was wondering if there is the possibility of this messing up with the system functionalities relying on having 2.7 as default. I suppose that there will no problems since 2.7 is still in /usr/bin, but I would like to be sure.
I have been using Anaconda Python.
I had a problem with the default Python installed on my Mac OSX 10.11 at one point, because of the numpy package.
It was a problem for me when I tried to run a script in Anaconda Python which relies on a numpy version higher the Mac default version and I wasn't able to get it working using conda install, pip install, or by changing the PATH/PYTHONPATH.
I was able to install the package but Anaconda Python would not recognize the new version.
I ended up removing the entire numpy that came with the Mac. But I do not think this would be a problem in the other way (i.e., using mostly the Mac python but occasionally install other packages for Anaconda Python) because the default Python does not look at the Ancondoa package directory.
Some background: I have an intel Mac osx (running Yosemite) and use PyCharm community edition as my main IDE. I usually code in Python 3.4 however, I'm taking some MIT OCW courses which all use Python 2. To make it easier on myself when using MIT's skeleton files I have downloaded Python 2.7 and switch the PyCharm interpreter depending on my project.
Here's my question:
I'm wondering if I would run into any trouble downloading the 2.7 and 3.4 versions of Anaconda.
If this is ok, would I need to do anything special with my import commands depending on which version of Python I'm coding in?
Thanks! Happy to add clarity / more info if this isn't enough to answer my questions.
There's no danger, but it's also not the recommended way of achieving this. Rather, you should use conda, the package manager that comes with Anaconda, to create an environment for the other version of Python. For instance, if you started with Anaconda3,
conda create -n python27 python=2.7 anaconda
would create an environment called python27 in ~/anaconda/envs/python27 with Python 2.7 and all the packages from Anaconda. You would then point to ~/anaconda/bin/python or ~/anaconda/envs/python27/bin/python depending on what version of Python you want. In the terminal, use source activate python27 and source deactivate to switch between the two.
See http://conda.pydata.org/docs/ for more information on conda.
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.