News for hackers. Stuff that matters.
Re:An Introduction to Unix (2014) by a3n on Saturday February 21, 2015 @10:24AM (#9085725)
How does it get weird with python? I do this day in, day out. I installed cygwin's python. When I'm in cygwin that's the python that runs, and when I'm in Windows it's my Windows python that runs.

Virtually all the scripts I write run without problems in either environment, because it's python. Scripts that other people wrote for Windows run fine in cygwin. There are occasions where I have to account for differences in the OS, but mostly never.

Re:An Introduction to Unix (2014) by kasabali on Sunday February 22, 2015 @07:29AM (#9089159)
I'll give an anectode from just last night. I wanted to fetch some online video, so I went ahead and downloaded youtube-dl-*.tar.gz, extracted it, and then tried to run it, all inside a cygwin session. For some reason, it did nothing. I ran file on the script and it claimed it was a data file. I run less on it and damn, it's a binary file. I was definitely surprised but didn't want to waste more time on it after fiddling for 10 minutes, I run the native Windows Python on the exact same file and it just worked.

I didn't look back so I don't know what was the main reason but I can say there are some problems.

Re:An Introduction to Unix (2014) by a3n on Sunday February 22, 2015 @08:24AM (#9089296)

  2424  pip install youtube-dl
  2425  which youtube-dl
  2426  youtube-dl --help
  2427  youtube-dl https://www.youtube.com/watch?v=WS-JcaPFzp4

  [youtube] WS-JcaPFzp4: Downloading webpage
  [youtube] WS-JcaPFzp4: Extracting video information
  [youtube] WS-JcaPFzp4: Downloading DASH manifest
  [download] Destination: The Renaissance and the cuckoo clock-WS-JcaPFzp4.mp4
  [download] 100% of 7.98MiB in 00:02

  2428  python --version
  2429  which python
  2430  history |tail
This worked fine for me. It installed, help was available, I downloaded the video and watched it.

I suspect one of two things, although it could be something else. You might be using the windows installation of python, rather than the cygwin installation. In most cases that works fine, but cygwin's python is compiled to expect a cygwin/unix-like environment, and windows python is compiled to expect windows. Sometimes weirdness ensues, and it's better to use cygwin's python in cygwin.

My other suspicion is that the installation of youtube-dl didn't happen correctly. Notice above that I used pip, which is offered in the installation instructions. If you've installed pip that's usually your best/first option. Their first instructions involve downloading the gz (as you did). I did that with wget in python, then noticed the installation is an extraction and a chmod; I'm usually more comfortable trying pip in that circmstance.

I've placed my email in my profile if you want to chat about this. I'll leave it there until I remember to remove it.

Edit: you can run the python shell, and it will summarize python's construction:

  $ python
  Python 2.7.8 (default, Jul 28 2014, 01:34:03)
  [GCC 4.8.3] on cygwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>>
From a windows cmd.exe shell:

  python
  Python 2.7.6 |Anaconda 2.1.0 (64-bit)| (default, Nov 11 2013, 10:49:15) [MSC v.1500 64 bit (AMD64)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  >>>
Re:An Introduction to Unix (2014) by a3n on Tuesday March 03, 2015 @08:22AM (#9137491)
Followup: I discovered/realized that, even though I was using cygwin's python, the windows python (Anaconda in my case) was still in my cygwin path, because the cygwin path has the windows path elements in it. You can see that if you run this, and see two pythons:

  which -a python
I discovered this when I ran pip and ipython in cygwin, and they "worked," i.e. something ran, but not right.

I put this at the end of my .bashrc to remove windows python from cygwin's path:

  export PATH=$(echo $PATH |sed -e "s/:[^:]*Anaconda[^:]*:/:/g" |sed -e "s/:[^:]*Anaconda[^:]*:/:/g")
There were two anaconda directories in the path, and /g should have taken care of both, but my RE-fu is apparently lacking, so brute force.

Cygwin has pitfalls.

Re:An Introduction to Unix (2014) by kasabali on Tuesday February 24, 2015 @07:02PM (#9104429)
Sorry I just saw your reply and I'm not on Windows right now. I'll check when I boot it.