ansible via virtualenv gives ERROR: [Errno 21] Is a directory - python

I have an issue globally on my iMac ( M1 incase it matters )
where the commands exit with import ansible module is missing
So I tried installing a tmp dir with virtual env and tried using Ansible from there w/o luck.
I'll start from the error:
$ ../venv/bin/ansible-inventory
ERROR: [Errno 21] Is a directory: '/private/tmp/testansible/z'
File structure is like this:
~/$ cd /tmp
tmp$ mkdir testansible && cd $_
testansible$ mkdir z
testansible$ virtualenv venv
testansible$ venv/bin/pip3 install ansible
Then in a different directory i'm trying to use it:
testansible$ cd z
z$ ../venv/bin/ansible-config init > ansible.cfg
Then running any ansible command gave me tons of errors:
ERROR: Invalid settings supplied for DEFAULT_GATHER_TIMEOUT
ERROR: Invalid settings supplied for DEFAULT_NULL_REPRESENTATION
ERROR: Invalid settings supplied for DEFAULT_REMOTE_PORT
ERROR: Invalid settings supplied for GALAXY_IGNORE_INVALID_SIGNATURE_STATUS_CODES
Which is strange by itself because their comments says that if there's no value - it will take some default from somewhere
Each one I "resolved" by commenting them out
Then the command worked:
z$ ../venv/bin/ansible-config init > ansible.cfg
But every other ansible command i'm trying to execute gives the same error:
z$ ../venv/bin/ansible -i inventory.hosts
ERROR: [Errno 21] Is a directory: '/private/tmp/testansible/z'
z$ ../venv/bin/ansible-inventory -i inventory.hosts
ERROR: [Errno 21] Is a directory: '/private/tmp/testansible/z'
Any ideas ?
Edit
Thanks to the comment below the issue was this line in the ansible.cfg file:
# (path) File to which Ansible will log on the controller. When empty logging is disabled.
log_path=
Commenting out this line - and the ansible commands started working.
I'm not sure , why across the file it says: When empty logging is disabled - but it's not disabled, it throws an exception. so as all the above variables, they don't really have a default value - they are just getting in the way

Related

Error with `pip freeze > requirements.txt`

I'm going through the Python Crash Course book and I'm on the section on deploying my app to Heroku. When trying to create the requirements.txt file, I get this error:
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp1252'>
OSError: [Errno 9] Bad file descriptor
I'm on windows and using the venv module. Running the command from the command prompt.
Double quote is not required .and put >> instead of > .

Makefile on Windows 10 - file not found

After some time I finally managed to successfully install python and pip and run it on my machine using Visual Studio Code.
I am working in virtual environment in python and we have a Makefile with following statement:
test:
source .env && PYTHONPATH=. PY_ENV=testing py.test ${ARGS} --duration=20
File .env lives in the main directory next to Makefile. It contains some environmental variables needed for testing certain APIs.
When I take the line out of the file and run it in my terminal, everything works fine and all tests are running etc.
However if I call the following: make test I am getting this error:
$ make test
source .env && PYTHONPATH=. PY_ENV=testing py.test --duration=20
/usr/bin/sh: line 0: source: .env: file not found
make: *** [test] Error 1
(venv)
To me it looks like when running this command from within Makefile it can't see the .env file but have no idea how to solve it.
The source command isn't looking up the file in the current working directory. As mentioned in man source:
Read and execute commands from filename in the current shell
environment and return the exit status of the last command executed
from filename. If filename does not contain a slash, filenames in
PATH are used to find the directory containing filename.
Change the file path like so:
test:
source ./.env && PYTHONPATH=. PY_ENV=testing py.test ${ARGS} --duration=20
Note that this error does not occur in bash version < 4. This is due to an implementation bug when run under POSIX mode (what make uses, since its default shell is sh, which is usually bash --posix). The correct behaviour was first mentioned in the documentation of bash-2.05 (revision 28ef6c31, file doc/bashref.info):
When Bash is not in POSIX mode, the current directory is searched if
FILENAME is not found in `$PATH'.
These older versions searched the current directory regardless of POSIX mode. It was only in bash-4.0-rc1 (revision 3185942a, file general.c) that this was corrected. Running git diff 3185942a~ 3185942a general.c outputs this section:
## -69,6 +69,7 ## posix_initialize (on)
if (on != 0)
{
interactive_comments = source_uses_path = expand_aliases = 1;
+ source_searches_cwd = 0;
}

command failed: ./distributr.sh -m "kivy" -d "main" [duplicate]

Trying to run Kivy with buildozer on Ubuntu 16.04,
(startup-demo-project pong) I get an error
on command
buildozer android debug deploy
After:
....
[DEBUG]: BUILD SUCCESSFUL
....
at the end of the build there is an error message:
....
IOError: [Errno 2] No such file or directory: u'/home/std/Dokumente/python
/Kivy/.buildozer/android/platform/build/dists/myapp/build/outputs
/apk/myapp-debug.apk'
My installation is according to:
http://buildozer.readthedocs.io/en/latest/installation.html
for Ubuntu 16.04.
Also
buildozer serve
does not show anything useful, only:
Directory listing for /
as response to call:
http://localhost:8000
Buildozer console says:
192.168.178.22 - - [15/Apr/2018 21:43:12] "GET / HTTP/1.1" 200 -
192.168.178.22 - - [15/Apr/2018 21:43:12] code 404, message File not found
Annotation:
I changed the log_level = 2 for more information, but could not figure out where to find the relevant log file or where to get more information about the error.
Problem
IOError: [Errno 2] No such file or directory: u'/home/std/Dokumente/python /Kivy/.buildozer/android/platform/build/dists/myapp/build/outputs /apk/myapp-debug.apk'
Solution
Use sudo to change and recompile android.py for Python 2.7. Please do the following at terminal window:
Step 1
Change directory
cd /usr/local/lib/python2.7/dist-packages/buildozer/targets
Step 2
Make backup copies of android.py and android.pyc
sudo cp android.py android-orig.py
sudo cp android.pyc android-orig.pyc
Step 3
Use an editor to make changes to android.py
sudo gedit android.py
Step 4
Insert the following import before import sys
from distutils.version import LooseVersion
Step 5
Add the following codes after line 791 (# XXX found how the apk name is really built from the title). Note: __sdk_dir (double underscore). Please refer to print screens below for details.
__sdk_dir = self.android_sdk_dir
build_tools_versions = os.listdir(join(__sdk_dir, 'build-tools'))
build_tools_versions = sorted(build_tools_versions, key=LooseVersion)
build_tools_version = build_tools_versions[-1]
gradle_files = ["build.gradle", "gradle", "gradlew"]
is_gradle_build = any((
exists(join(dist_dir, x)) for x in gradle_files)) and build_tools_version >= '25.0'
if is_gradle_build:
Step 6
Save the changes.
Step 7
Compile android.py
At shell prompt
sudo python -m py_compile a--ndroid.py
or invoke Python Interpreter Interactive Shell
sudo python
>>> import py_compile
>>> py_compile.compile('android.py')
Step 8
At your project folder, run
buildozer android debug
Pictures
Changes Part 1 - from distutils.version import LooseVersion
Changes Part 2
Compile android.py
After Changes # local Buildozer - App deployed to Acer Android tablet
After Changes # Buildozer VM - Successful APK
Before Changes # local Buildozer - IOError: [Errno 2] No such file or directory
Before Changes # Buildozer VM - IOError: [Errno 2] No such file or directory

Python copy file with Fabric - Windows to Debian

I am trying to use Python Fabric to copy a file from Windows to a debian system.
SOURCE: The Windows folder is C:\Users\UserN\Downloads contains the file test_celsius.out.
DESTINATION: The Debian folder is /mnt/Reado/RoTempValC.
I can move other files from the SOURCE to the DESTINATION using WinSCP. However, I need to use Fabric to move this particular file.
I can use Fabric to change into this directory and list its current contents:
ls /mnt/Reado/RoTempValC
Here is what I have tried - in a Fabric task named move() I have this
run('mv C:\Users\UserN\Downloads\test_celsius.out /mnt/Reado/RoTempValC')
Now, here is the output:
.
.
.
.
[10.10..] Executing task 'move'
[10.10..] run: mv C:\Users\UserN\Downloads\test_celsius.out /mnt/Reado/RoTempValC
[10.10..] out: mv: rename C:/Users/UserN/Downloads/test_celsius.out to /mnt/Reado/RoTempValC/test_celsius.out: No such file or directory
[10.10..] out:
Disconnecting from 10.10.. done.
Fatal error: run() received nonzero return code 1 while executing!
Requested: mv C:/Users/UserN/Downloads/test_celsius.out /mnt/Reado/RoTempValC
Executed: /bin/bash -l -c "mv C:/Users/UserN/Downloads/test_celsius.out /mnt/Reado/RoTempValC"
Aborting.
I am not sure why it is doing this. I can correctly list the contents of the directory in Debian by using the ls command above.
Is there a way to copy this file?
EDIT:
Additional Information:
I am running the above fab move command from the Windows command
prompt.
I opened the command prompt and typed cd Python27\SGTemp
since this is where the fabfile.py is located.
Then I ran fab move.
EDIT 2:
I replaced /mnt/Reado/RoTempVal by /mnt/Reado/RoTempValC/ but got the same output as above.
Try fabric.operations.put(*args, **kwargs):
put('C:\Users\UserN\Downloads\test_celsius.out', '/mnt/Reado/RoTempValC')

Error integrating Pylint on Wing IDE

After successful installation on Pylint on my Windows OS, I am able to run it on command prompt to check any python file.
But when I integrate PyLint on Wing IDE v 5.0, I am getting below error on checking any python file
Error executing PyLint: Command failed with error=None, status=2; stderr:
python: can't open file 'C:\Python27\Scripts\pylint': [Errno 2] No such file or directory
Am I missing something to install or pre-configure. I have set the location of Pylint.bat in PATH variable already.

Categories