aws cli in cygwin - how to clean up differences in windows and cygwin style paths

2024/10/13 9:15:33

I suspect this is my ineptitude in getting path variables set right, but I'm at a loss.

I've installed the aws cli using pip in cygwin.

pip install awscli

I have two python environments... a windows anaconda distribution, and the version cygwin can install for you.

which python 
> /usr/bin/pythonwhere python
> C:\cygwin64\bin\python
> C:\windows-style-path-to-anaconda\python.exe

when I try to run aws cli

aws --version
> C:\windows-style-path-to-anaconda\python.exe: can't open file 
> 'cygdrive/c/cygdrive-style-path-to-anaconda/Scripts/aws': 
> [Errno 2] No such file or directory'

I've tried adding the path to aws to my windows path variable. No luck.

I've tried adding this to my .bashrc

export PATH="$PATH:/cygdrive/c/cygdrive-style-path-to-anaconda/Scripts"

No luck.

I've tried modifying the 'aws' that python is trying to run. First I modified the #! to point to the cygwin python instead of the windows python.

#!c:\cygwin64\bin\python

then it could find the file 'aws' to run... but it couldn't find any of the files to import... 'awscli.clidriver', 'botocore._', etc.

I tried modifying my path variables to point to the location of these... anaconda/Lib/site-packages... I even tried doing a sys.path.insert(1, path) in the 'aws' file itself.... it fixed that problem but every single file it loaded was looking in other places and not finding them, and it was too many things to mess with one at a time in the aws .py files.

here's what sort of works... in cygwin...

cd /cygdrive/c/cygwin-path-to-anaconda/Scripts
./aws --version
> aws-cli/1.10.26 Python/2.7.11 Windows/7 botocore/1.4.17

but there has to be a better way, right? either...

  • get my path variables set right

  • get the aws cli installed in the cygwin python directory instead of the windows anaconda environment

unfortunately, pip uninstall just hangs trying to remove awscli, and I don't know how to force it to use the cygwin python if I even could uninstall/reinstall. And after a bunch of tries at fixing my path variables, I'm at a loss.

Any advice appreciated.

Answer

When running pip install awscli from cygwin, it may install awscli in Window's Anaconda Python installation, instead of in Cygwin's Python (which is what you want). Then, when running aws, you will get an error that the aws executable can't be found. The solution I found was installing python/pip inside cygwin by following below bash commands from cygwin shell:

pip uninstall awscli
wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
apt-cyg install python
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install awscli

Make sure you have wget installed in cygwin.

https://en.xdnf.cn/q/69547.html

Related Q&A

Print all variables and their values [duplicate]

This question already has answers here:too many values to unpack, iterating over a dict. key=>string, value=>list(8 answers)Closed 6 years ago.This question has been asked quite a bit, and Ive tr…

How to emulate multiprocessing.Pool.map() in AWS Lambda?

Python on AWS Lambda does not support multiprocessing.Pool.map(), as documented in this other question. Please note that the other question was asking why it doesnt work. This question is different, Im…

Tkinter overrideredirect no longer receiving event bindings

I have a tinter Toplevel window that I want to come up without a frame or a titlebar and slightly transparent, and then solid when the mouse moves over the window. To do this I am using both Toplevel.…

Reusing Tensorflow session in multiple threads causes crash

Background: I have some complex reinforcement learning algorithm that I want to run in multiple threads. ProblemWhen trying to call sess.run in a thread I get the following error message:RuntimeError: …

Conditional column arithmetic in pandas dataframe

I have a pandas dataframe with the following structure:import numpy as np import pandas as pd myData = pd.DataFrame({x: [1.2,2.4,5.3,2.3,4.1], y: [6.7,7.5,8.1,5.3,8.3], condition:[1,1,np.nan,np.nan,1],…

Need some assistance with Python threading/queue

import threading import Queue import urllib2 import timeclass ThreadURL(threading.Thread):def __init__(self, queue):threading.Thread.__init__(self)self.queue = queuedef run(self):while True:host = self…

Python redirect (with delay)

So I have this python page running on flask. It works fine until I want to have a redirect. @app.route("/last_visit") def check_last_watered():templateData = template(text = water.get_last_wa…

Python Selenium. How to use driver.set_page_load_timeout() properly?

from selenium import webdriverdriver = webdriver.Chrome() driver.set_page_load_timeout(7)def urlOpen(url):try:driver.get(url)print driver.current_urlexcept:returnThen I have URL lists and call above me…

Editing both sides of M2M in Admin Page

First Ill lay out what Im trying to achieve in case theres a different way to go about it!I want to be able to edit both sides of an M2M relationship (preferably on the admin page although if needs be …

unstacking shift data (start and end time) into hourly data

I have a df as follows which shows when a person started a shift, ended a shift, the amount of hours and the date worked. Business_Date Number PayTimeStart PayTimeEnd Hours 0 2019-05-24 1…