Installing a package to Canopy - python

I'm really new to coding, programming, Python, and just computers in general, so I need some help with Canopy. I've been having pretty consistent troubles installing any packages to Canopy; some stuff is in the internal package manager,but whenever it isn't, it's really confusing. I guess I'll list a specific installation.
I'm trying to install "pywcs" (link provided below) to my Win7 64-bit machine. I have Cygwin if that helps at all. I do not know how to go about this; the stuff I found online is pretty confusing, and Cygwin easy_install (filename) never seems to work. Any step-by-step solutions?

The way I installed astropy is as follows.
Open Windows Terminal
Change Directory to C:\Users\<USER NAME>\AppData\Local\Enthought\Canopy32\User\Scripts
Type easy_install.exe astropy
Wait until the download completes, and restart Enthought.

sometimes installing packages can be hard for enthought canopy . You could install all python packages using pip install mrjob command on the its own canopy command prompt
Go to tools tab on the canopy editor ,
Left click on the canopy command prompt ,
Finally pip install <package name> and hit Enter key

The key point is that in order to install a package into any Python distribution (including Canopy Python), you should use that Python to perform the installation. You refer to Cygwin's "easy_install", but you should instead use Canopy's easy_install.
As described in this article, the easiest way to be sure that you are running Canopy's Python (and Canopy's easy_install) is to have Canopy Python on your PATH. This is done by default during Canopy installation, but if you uncheck this option then, or if your Cygwin installation doesn't use your Windows PATH, then you will need to adjust your Cygwin PATH accordingly.
Doing as Sukrit suggests, and running the installation from the Canopy Python Scripts directory, is also a reasonable approach.
Alternatively, depending on its compiler dependencies, you may be able to install astropy from a Windows Command Prompt rather than from Cygwin (of course Canopy must be on the PATH here too, as it would be by default.)

In Linux you can do it as follows.
1) Make sure you are using the Canopy version of Python - check out https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-User-Python-from-the-command-line
2) At the command prompt use easy_install, for example:
$ easy_install pp==1.5.7
to install version 1.5.7 of pp

Just for information, Astropy is now included by default in Enthought Canopy:
https://www.enthought.com/products/canopy/package-index/

Related

pycharm interpreter using cygwin version python

I am running django python2.7 using Pycharm in windows.
Now I have some issue with redis queue not working in windows because of this
I am trying to do what this person did here. Use a cygwin version of python as pycharm interpreter.
(not sure if I downloaded all the packages or did correct steps)
I downloaded cygwin and install packages python2.7 + python-setuptools and then try to point my Pycharm interpreter to c:/cygwin/bin/python27.exe
see image
After that it seem ok and ask me to install packing tools pip, I clicked it and it give me this error:
see image
"Cannot start process, the working directory '\cygdrive\c\Users\User1G~1.SIS\AppData\Local\Temp\1\tmpYpudf2pycharm-management\pip-7.1.0' does not exist"
According to the error message it looks like pip can't be found... Are you sure you have installed pip?
Take a look here, how you can install pip: Installing Pip-3.2 on Cygwin
You can open a cygwin command line window and try to manually install the packages you want to.

How to use easy install on Canopy Enthought?

I have installed the latest version of Enthought, I have the free express version. and I want to install the pyodbc package.
I have gathered that I need to use easy_install to install pip to install pyodbc.
However, I have no luck in using easy_install or even enpkg.
If I open enthought editor and type in:
enpkg pip
or
easy_install pip
all I am getting in return is syntax errors.
(I am very inexperienced with using external packaged that are not already installed into Enthought.)
What exactly are the syntax errors? I am guessing you are typing this into the python shell shown by the enthought editor?
What you need to do is open up a command shell. Are you on Windows? Try running cmd.exe - Canopy might even provide a special shell to use (with paths all set up for you) so check the start menu.
Then, you should be able to use easy_install and enpkg. You should see a prompt similar to:
C:\Users\Sameer\>
Type it at that prompt.
The python prompt looks like this:
>>>
You can't run enpkg or easy_install from there. Well... technically you can by shelling out, but first, try the above.

Python & Windows: Where is the python launcher?

I'm trying to use different versions of python on win7, and I was told that I can use the python laucher.
I find the docs for it: https://docs.python.org/3/using/windows.html#launcher
But I don't know where is it. Someone say its called py.exe, but there is no file with this name on my computer.
I installed python 3.4.3 with Anaconda, https://store.continuum.io/cshop/anaconda/, comes with Scipy
===========
UPDATE:
Since there is no python launcer in Anacoda, how can I re-install it? Or if there is better way of using different version on Win7?
It should be in the root directory of Python 3.3 installs and higher. It is not available for Python2.
Go to C:\PythonXX\ and you should find py.exe for your version.
In Command Prompt or your favorite shell (like Cygwin), run:
py -3.3 -m path/to/myscript.py
However, this only works if you have a 3.3 or higher installed.
EDIT: Anaconda does not come with Python launcher. It is only available for an ActiveState, standard, or probably many other installs.
EDIT2: Here are two brand-new, Python 3.4 installs of ActiveState Python and Anaconda Python, screenshotted. Notice how Anaconda Python does not include py.exe and a lot of other (non-essential) executables?
EDIT3: After some "difficult" testing, just set anaconda as your default install for Python3.4 and grab the py.exe from another install. That is all. So you can install Python3.4 from another source, uninstall it, and save the py.exe, make sure it is in the system path, and the python launcher is fully installed.
EDIT4: Actually there's also a standalone installer available here:
https://bitbucket.org/vinay.sajip/pylauncher/downloads
If installing python from python.org's downloads and you select "[x] install pylauncher [x] install for all users", py.exe is installed in C:\Windows\py.exe.
I think if you don't install for all users, then it's in the python install root.
If you are able to run py from cmd.exe, then you can find out where it is with where py.exe.
It looks like the python executable is part of the conda command if you're using Anaconda, according to their website. According to Alexander Huszagh (see his answer), the python launcher doesn't come with Anaconda python.
Here is a blog post that is perhaps relevant.
I first tried everything Alexander Huszagh has written. But none of it helped.
It took me a really long time to find the Python Launcher. I had accidentally changed how to open .py-files. And once you change it, you can't do right mouse click "Edit with IDLE" anymore. I eventually found them in the C:\Windows\ directory named py.exe.
The experts gave a reply which seems relevant to one version of python but not the latest version. e.g. In my least favorite command line tool I entered:
C:\Program Files (x86)\Python36-32>dir py.exe /s
It replied:
File Not Found

Difficulty running regetron in cmd

I want to follow the regex tutorial on http://regex.learncodethehardway.org/book/learn-regex-the-hard-waych1.html, but I am unsure how to execute regetron in cmd. I have followed the instructions to install it and the python interpreter does not give me an error when I type import regetron, so I know for certain it is installed.
Scripts usually get installed into the Scripts folder of your Python installation under Windows. Assuming you have Python 2.7 installed in the typical location, you should find a regetron executable in C:\Python27\Scripts.
FWIW, I typically put both C:\Python27 and C:\Python27\Scripts on my path under Windows for the above reason. Then commands introduced by packages are immediately available on the command line.
UPDATE: Regetron doesn't currently work for Windows. I've proposed a couple of patches to make it work. In the meantime, you can grab a new .zip from here and use pip to install it:
pip install .\regetron-1.4-windows.zip
UPDATE: My fixes have been incorporated into regetron. It should now work fine under Windows in a future version of regetron.
I used Cygwin to run regetron, and I did the following:
Install Cygwin, or update it if you already have it installed
Install Python when you pick your packages to install. Install wget,
too, because it'll make one of the steps below easier
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
Use easy_install to install PIP. PIP is actively maintained, and supports package removal (unlike easy_install): easy_install pip
pip install regetron
Run regetron: regetron
Another word of caution: cmd.exe handles single-quoted (')and double-quoted strings (") differently than *nix shells. I've been burned when I've run Python scripts that take regex arguments (e.g. pywikipediabot) in cmd.exe. You can follow examples exactly, and the Wrong Thing will happen.
Cygwin doesn't have problems with ' and ".

What is the best way to install python 2 on OS X?

A colleague of mine wants to use my python 2 code on his OS X (10.6) machine. My code imports several built-in python packages, including Tkinter and shelve, and also uses third-party packages, including numpy, scipy, matplotlib, and ipython.
I've encountered a few problems with OS X's built-in python. (IDLE doesn't work, for example*). I suspect I should install a more recent version of python, and a different version of Tk.
My questions:
Will having two different versions of python/Tk on the same machine cause problems?
I would like to associate the terminal commands 'python', 'ipython', and 'easy_install' with the more recent version of python. How should I do this?
When I install third-party packages like numpy using a .dmg file, how do I control which version of python numpy installs into?
Is there a better way to do this?
If this process goes well, I'd consider adding OS X instructions to my code's documentation, so I'd like to boil down this process to the simplest, most general approach.
*EDIT: Also, this
EDIT: Thank you everyone for the useful answers. My colleague tried MacPorts, which seems to work well, but has a few speedbumps. First we had to install Xcode from the system install disk. This is not a fast or lightweight install (several GB). Luckily we still had the disk! Once Xcode was installed, MacPorts was easy to install. Python and the python subpackages we needed were also easy to install, but he told me this installation took several hours. Presumably this delay is due to compilation? He had an easy time setting the MacPorts python as default. However, I think we have to change the 'Python Launcher' application by hand, this seems to still default to the system python.
Even though he has a working system now, I'm tempted to ask him to try one of the other solutions. I'm not sure all of my code's potential users will tolerate a multi-hour, multi-gigabyte installation.
I use brew to install all my libraries/compilers/interpreters.
To install python try this:
brew install python
Then add Python's binaries directory to your $PATH in your ~/.profile:
export PATH=`brew --prefix python`/bin:$PATH
I'd recommend you to install pip, virtualenv and virtualenvwrapper to have better control over your environment too.
Have you tried ActivePython?
It includes a package manager (PyPM) that, by default, installs into your home directory (eg: ~/Library/Python/2.7). Main scripts get symlinked in /usr/local/bin; use the included pythonselect to set the active Python version.
You don't have to bother installing .dmg packages, as PyPM is a binary package manager ... therefore you can install non-pure Python packages like NumPy without having to compile things yourself.
ActivePython can use Apple's Tcl/Tk or, if installed, ActiveTcl.
A "simplest, most general approach" in your documentation could be:
Install ActivePython 2.7
Open Terminal and type pypm-2.7 install matplotlib ipython
Using MacPorts, you can install python 2.6, 2.7, 3.1 and 3.2 at the same time, with their own packages, without ever touching the built-in python.
numpy, scipy, matplotlib, and ipython are also available as ports for most of those python versions.
Moreover, if you install the python_select port, you'll be able:
to choose which one of those (plus the built-in python) is the "default" python;
to install python packages through easy_install/pip for the "selected" python, if they're not available as ports.
Add virtualenv to the mix, and you'll have a very, very flexible Python development environment.
As for your questions:
Q1: with MacPorts, no. while not a frequent user, I've installed and used matplotlib in 2.6 and 2.7, switching between the two using python_select.
Q2: easy_install, pip, ipython will be "linked" to the python they were installed by. (but see tip 1)
Q3: it's easier to install one of the py{26,27,xx}-numpy ports, or pip install numpy under your python_select'ed python.
Q4: well, MacPorts is the best thing I know after APT on Debian/Ubuntu... :-)
Now, two tips if you try MacPorts:
MacPorts cleanly installs ports separately from the OS X installation, in an /opt/local directory, and each python version is installed in a /opt/local/Library/Frameworks/Python.framework/Versions/{2.5,2.6,2.7,...} directory. Using python_select cleanly switch the "python" command using links. BUT... the Versions/{2.5,2.6,2.7,...}/bin directory, where python scripts are installed, is not added to the PATH. Just adding: export PATH=/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH to your ~/.profile will always give you direct access to the scripts installed for the selected python.
to avoid bad surprises, I've added a echo Selected python is \"$(python_select -s)\" line to my ~/.profile, so I always know which is my currently selected python when opening a session... :-)
Regards,
Georges
In almost all cases, the best python to use is the one from http://python.org/. It sets up the paths correctly and doesn't overwrite anything. DMG package installs usually work automatically, as does python setup.py install, and it's not too hard to get setuptools to work. If you want per-user installs, it is easy to set up .pydistutils.cfg and python automatically recognizes the path install_lib = ~/Library/Python/$py_version_short/site-packages
An addendum regarding the usage of brew:
Since some time, brew install python will install python3.
If you intend to install python2, you want to use
brew install python#2
It is perfectly fine to install both python and python3 using brew!
Here is an old post that answers your questions too.
In general it is not a problem at all to have more than one python installation on your machine. You just have to watch out which one you are calling on the command line.
>> which python
... helps to identify where your python binary is located. The original Mac OS X python is usually at "/usr/bin/python"
I personally use the MacPorts python installation. It also supports you with the installation of modules. (see link above)
I have 4 versions of python on my MacBook Pro. 2 from the original install of OS X 10.6 and a subsequent update, then self installed copies of python 2.7 and 3.2. You can update the python command to point at any of the versions. They all install in separate directories and cause no problems with each other.
I'm not sure what will happen when you install from a .dmg file. I believe it will simply use whatever version python points to.
This post on superuser.com answers your questions on changing default paths.

Categories

Resources