I have tried installing ansible through pip install ansible but whenever i get the following error trying to use it:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\ruan.greyling\AppData\Local\Programs\Python\Python311\Scripts\ansible.exe\__main__.py", line 4, in <module>
File "C:\Users\ruan.greyling\AppData\Local\Programs\Python\Python311\Lib\site-packages\ansible\cli\__init__.py", line 42, in <module>
check_blocking_io()
File "C:\Users\ruan.greyling\AppData\Local\Programs\Python\Python311\Lib\site-packages\ansible\cli\__init__.py", line 34, in check_blocking_io
if not os.get_blocking(fd):
^^^^^^^^^^^^^^^
AttributeError: module 'os' has no attribute 'get_blocking'
I have python and pip installed on the machine.
It looks like this may be a version compatibility issue with Python 3.11. I recommend upgrading to the latest version of Python and then running the command again.
This is why you are getting this error.
Windows without WSL is not natively supported as a control node (more in the documentation)
If you want to run the Control node on Windows use WSL
Good practice code repository and sync to your Linux Control node from Windows machine.
Related
I am trying to install poetry using the following command
curl -sSL https://install.python-poetry.org | python3 -
but it is failing with the following exception:
Exception: This build of python cannot create venvs without using symlinks
Below is the text detailing the error
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
/Users/DaftaryG/.local/bin
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.2.1): Creating environment
Traceback (most recent call last):
File "<stdin>", line 940, in <module>
File "<stdin>", line 919, in main
File "<stdin>", line 550, in run
File "<stdin>", line 571, in install
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/contextlib.py", line 117, in __enter__
return next(self.gen)
File "<stdin>", line 643, in make_env
File "<stdin>", line 629, in make_env
File "<stdin>", line 309, in make
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/venv/__init__.py", line 66, in __init__
self.symlinks = should_use_symlinks(symlinks)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/venv/__init__.py", line 31, in should_use_symlinks
raise Exception("This build of python cannot create venvs without using symlinks")
Exception: This build of python cannot create venvs without using symlinks
I already have symlinks installed so not having that does not seem to be the problem. Would anyone know the cause of this error?
Not the best solution, but you can install it using Homebrew, if you have it. That's what I did.
brew install poetry
I had the same error.
In my case, the problem was the global version of python set by pyenv was not python 3.x.
So
pyenv global 3.x.x
fixed it.
For anyone looking for an alternative to homebrew for installation, the discussion on this poetry issue helped me find a solution:
The issue here is the macOS-provided python is not relocatable, so venv creates a broken python when using --copies / symlinks=False as our installer does.
Essentially, to solve this problem, download a distribution of python directly from python.org. For whatever reason, the poetry installation command isn't compatible with whatever distribution comes pre-built on a Mac.
I was making a Tetris game and at the top of the Python code, I put in import pygame, since that was the thing I was thinking of doing and the thing I thought I could only do. My game was complete, the terminal was open, and I ran the code. The terminal gives an error:
Traceback (most recent call last):
File "[removed for safety]", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
So I tried pip installing it with the command pip install pygame, but it just returns a similar error:
Traceback (most recent call last):
File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python34\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Python34\lib\site-packages\pip\__init__.py", line 1, in <module>
from typing import List, Optional
ImportError: No module named 'typing'
I was using
VSCode, with Python version 3.10.5, 64-bit.
First of all you can uninstall python 3.4 from your system, with this link then you can reinstall python from from the python.org website. Then hopefully pip install pygame would work. Or, if pygame is installed run pip uninstall pygame then pip install pygame
File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
Python34 is mentioned in the error code, which indicates that the terminal runtime retrieves python3.4 instead of 3.10 you mentioned.
This indicates that there are multiple versions of Python in your environment.
You can manually select the Python interpreter by using shortcut "ctrl+shift+P" and typing "python: select interpreter" or click this icon to change the interpreter:
After choosing the correct interpreter, you can use command pip install pygame to install python package at the correct python-lib.
I have created a python module. Works on ubuntu/xenial with python3.5. I built it and uploaded to python repository. Then I created virtual environment, installed this module and tried to run. As a result I got:
(hdfnc_venv) svc#PL1LXD-529389:~/$ python3 -m my_package.my_module -h
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/svc/hdfnc_venv/lib/python3.5/site-packages/my_package/my_module.py", line 4, in <module>
import docker
File "/home/svc/hdfnc_venv/lib/python3.5/site-packages/docker/__init__.py", line 2, in <module>
from .api import APIClient
File "/home/svc/hdfnc_venv/lib/python3.5/site-packages/docker/api/__init__.py", line 2, in <module>
from .client import APIClient
File "/home/svc/hdfnc_venv/lib/python3.5/site-packages/docker/api/client.py", line 222
f'Error while fetching server API version: {e}'
^
SyntaxError: invalid syntax
So apparently there are multiple issues here. One is this invalid syntax which I suppose is because python3.5 does not recognize f-string syntax introduced in python3.6. Wasn't there an f-string, an exception would be raised anyway.
The bigger problem is why it there is error with just importing docker. Docker is properly installed on this machine, so is the module docker (5.0.3) in my venv. The module works when I run it directly in the system from the source code, not from my venv installation. Also when I run it this way, python3.5 works just fine, so invalid_syntax is not a problem anymore - most likely python didn't reach this part of the code, which means it managed to import docker module (also 5.0.3) without any problem.
I'm using my company's VM which already has Python 2.7 (comes with the OS) and Python 3.6.13 (Installed by the company)
Recently, there is a need to upgrade an application to latest version of Python ie: 3.10.2
So, I installed Python 3.10.2 in a local directory inside my $HOME. I referred to this link for the installation link.
While 2.7 & 3.6 are already there in the system.
Now, when I try to create a VENV with this python version (3.10.2), I see this error:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 69, in <module>
import msvcrt
ModuleNotFoundError: No module named 'msvcrt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/venv/__init__.py", line 10, in <module>
import subprocess
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 74, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
I found some solutions like this one: link but I cannot figure out how it will translate in my case since my installation directory is not /usr/local/... It is $HOME/path/to/dir
Python on Linux does not have the msvcrt module at all. It's strictly Windows only. You seem to have miscompiled your Python somehow, since it also doesn't have the _posixsubprocess module (and msvcrt is used for Windows detection in subprocess.py).
May I recommend using pyenv or asdf for custom Python versions? They're less likely to miscompile Python.
OSX, Python 2.7, pip, virtualenv. Been using these for years with no issues.
I'm not sure what changed, but recently my environment completely broke for Django after working perfectly fine for a while. The same checkout runs fine on my friend's computer with a similar setup.
Things I've already tried: deleting my venv and creating a new one with fresh installs from requirements.txt, uninstalling logging outside the venv and reinstalling inside, reinstalling pip.
I get the same traceback for any manage.py command. It appears to be having issues with the logging module:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/core/management/__init__.py", line 376, in execute
sys.stdout.write(self.main_help_text() + '\n')
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/core/management/__init__.py", line 242, in main_help_text
for name, app in six.iteritems(get_commands()):
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/core/management/__init__.py", line 109, in get_commands
apps = settings.INSTALLED_APPS
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/conf/__init__.py", line 52, in __getattr__
self._setup(name)
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/conf/__init__.py", line 48, in _setup
self._configure_logging()
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/conf/__init__.py", line 75, in _configure_logging
logging_config_func(DEFAULT_LOGGING)
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/utils/dictconfig.py", line 555, in dictConfig
dictConfigClass(config).configure()
File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2. 7/site-packages/django/utils/dictconfig.py", line 323, in configure
del logging._handlerList[:]
AttributeError: 'module' object has no attribute '_handlerList'
It seems that you installed outdated 0.4.9.6 version of logging module, presumably with pip. Correct version, shipped with python 2.7 is 0.5.1.2, and I suppose in your case might be located in /Library/Python/2.7/lib/logging. Correct version can be uploaded from python svn.
If you use pip, you always can find out which module versions are installed with
$ pip freeze
to ensure that correct versions of packages are installed, use following syntax:
$ pip install <package>==<version>
this will save you lot of pain and efforts, and almost a must on production environments.