My current project is using Python 2.7 which I can't change. I have a simple Python test script called env_test.py that contains
import os
print('\n\nPYTHONPATH environment variable is: ' + os.environ.get('PYTHONPATH'))
I have a launch session to debug Python script
{
"name": "Run integration test script",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/test/fte_test/integration/test_scripts/${input:IntegrationScripts}",
"args": [
"--dut_type=mint",
"--command_timeout=180",
"--compact_log",
"--elog_only=1"
],
"stopOnEntry": false,
"cwd": "${workspaceFolder}/test/fte_test",
"sudo": true,
"python": "/usr/local/micron/bin/python2.7",
"envFile": "${workspaceFolder}/dev.env",
"console": "integratedTerminal"
},
The dev.env file contains the following
# dev.env - development configuration
PYTHONPATH=/users/lordhog/projects/XXXXXX/repo/test/fte_test
When the debug session is launch the following error is reported
[fte_test]$ /usr/bin/env sudo -E /usr/local/XXXXXX/bin/python /users/lordhog/.vscode-server/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/launcher 39257 -- /users/lordhog/projects/YYYYYYY/repo/test/fte_test/integration/test_scripts/cs/evn_test.py --dut_type=mint --command_timeout=180 --compact_log --elog_only=1
Traceback (most recent call last):
File "/usr/local/XXXXXX/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/local/XXXXXX/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/users/lordhog/.vscode-server/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module>
from debugpy.server import cli
File "/users/lordhog/.vscode-server/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module>
import debugpy._vendored.force_pydevd # noqa
File "/users/lordhog/.vscode-server/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 37, in <module>
pydevd_constants = import_module('_pydevd_bundle.pydevd_constants')
File "/usr/local/XXXXXX/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/users/lordhog/.vscode-server/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py", line 362, in <module>
from _pydev_bundle._pydev_saved_modules import thread, threading
File "/users/lordhog/.vscode-server/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py", line 94, in <module>
import _thread as thread; verify_shadowed.check(thread, ['start_new_thread', 'start_new', 'allocate_lock'])
ImportError: No module named _thread
When running the script at the command line it does run
[fte_test]$ sudo -E PYTHONPATH=/users/lordhog/projects/XXXXXXX/repo/test/fte_test /usr/local/YYYYYY/bin/python2.7 ./integration/test_scripts/cs/env_test.py
PYTHONPATH environment variable is: /users/lordhog/projects/XXXXXXX/repo/test/fte_test
[fte_test]$
What seems odd to me is the command that VS Code issues. There are no parameters after "-E" . Seems this is where VS Code should insert the environment variable found in the dev.env file. Immediately after "-E" is the Python interpreter path.
Instead of using the envFile parameter in the launch.json file I also tried while removing the envFile parameter
"env": {
"PYTHONPATH": "${workspaceFolder}/test/fte_test",
},
Launching the debug session results in the same error. What am I doing wrong?
Related
I want download file from s3 using ansible.
- name: Download file from S3
amazon.aws.aws_s3:
aws_access_key: "XXXXXXXXXXXXXXXXXXXXX"
aws_secret_key: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxx"
bucket: "bucket-name"
mode: "get"
object: "file1"
dest: "/home/centos/file1"
I am getting error like this:
TASK [Download file from S3] *************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: SyntaxError: invalid syntax
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/centos/.ansible/tmp/ansible-tmp-1634047142.42-9501-194847033388166/AnsiballZ_aws_s3.py\", line 102, in <module>\n _ansiballz_main()\n File \"/home/centos/.ansible/tmp/ansible-tmp-1634047142.42-9501-194847033388166/AnsiballZ_aws_s3.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/centos/.ansible/tmp/ansible-tmp-1634047142.42-9501-194847033388166/AnsiballZ_aws_s3.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.amazon.aws.plugins.modules.aws_s3', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\n fname, loader, pkg_name)\n File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\n exec code in run_globals\n File \"/tmp/ansible_amazon.aws.aws_s3_payload_GMJ5WC/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/modules/aws_s3.py\", line 360, in <module>\n File \"/tmp/ansible_amazon.aws.aws_s3_payload_GMJ5WC/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/core.py\", line 74, in <module>\n File \"/tmp/ansible_amazon.aws.aws_s3_payload_GMJ5WC/ansible_amazon.aws.aws_s3_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/ec2.py\", line 65, in <module>\n File \"/usr/lib/python2.7/site-packages/boto3/__init__.py\", line 16, in <module>\n from boto3.session import Session\n File \"/usr/lib/python2.7/site-packages/boto3/session.py\", line 17, in <module>\n import botocore.session\n File \"/usr/lib/python2.7/site-packages/botocore/session.py\", line 30, in <module>\n import botocore.client\n File \"/usr/lib/python2.7/site-packages/botocore/client.py\", line 16, in <module>\n from botocore.args import ClientArgsCreator\n File \"/usr/lib/python2.7/site-packages/botocore/args.py\", line 26, in <module>\n from botocore.signers import RequestSigner\n File \"/usr/lib/python2.7/site-packages/botocore/signers.py\", line 19, in <module>\n import botocore.auth\n File \"/usr/lib/python2.7/site-packages/botocore/auth.py\", line 121\n pairs.append(f'{quoted_key}={quoted_value}')\n ^\nSyntaxError: invalid syntax\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
ansible --version
[WARNING]: log file at /etc/ansible/logs/ansible.log is not writeable and we cannot create it, aborting
ansible 2.9.25
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/icmqa/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Ansible 2.9.17 - During inventory check facing parsing.dataloader module not found error
Did not see this issue with Ansible 2.6.
Configs:
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /opt/ansible/2.9.17/lib/python2.7/site-packages/ansible
I can see dataloader.py in the above python module location.
Below error:
Friday 26 February 2021 05:36:33 +0000 (0:00:06.250) 0:00:06.283 *******
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named parsing.dataloader
fatal: [xts-vm-tsa5-centos -> xts-vm-diag9]: FAILED! => {"changed": false, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/xsight/.ansible/tmp/ansible-tmp-1614317794.33-18549-218205673346029/AnsiballZ_inventory_checks\", line 102, in <module>\r\n _ansiballz_main()\r\n File \"/home/xsight/.ansible/tmp/ansible-tmp-1614317794.33-18549-218205673346029/AnsiballZ_inventory_checks\", line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/home/xsight/.ansible/tmp/ansible-tmp-1614317794.33-18549-218205673346029/AnsiballZ_inventory_checks\", line 40, in invoke_module\r\n runpy.run_module(mod_name='ansible.modules.inventory_checks', init_globals=None, run_name='__main__', alter_sys=True)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\r\n fname, loader, pkg_name)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\r\n mod_name, mod_fname, mod_loader, pkg_name)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n exec code in run_globals\r\n File \"/tmp/ansible_inventory_checks_payload_8R32eJ/ansible_inventory_checks_payload.zip/ansible/modules/inventory_checks.py\", line 11, in <module>\r\nImportError: No module named parsing.dataloader\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
I am running celery 4.1.1 on windows and sending requests to redis(on ubuntu), Redis is properly connected and tested from windows side. But when i run this command
celery -A acmetelbi worker --loglevel=info
i get this long error:
[tasks]
. accounts.tasks.myprinting
. acmetelbi.celery.debug_task
[2019-08-02 11:46:44,515: CRITICAL/MainProcess] Unrecoverable error:
PicklingErr
or("Can't pickle <class 'module'>: attribute lookup module on builtins
failed",)
Traceback (most recent call last):
File "c:\acmedata\virtualenv\bi\lib\site-
packages\celery\worker\worker.py", line 205, in start
self.blueprint.start(self)
File "c:\acmedata\virtualenv\bi\lib\site-packages\celery\bootsteps.py",
line 119, in start step.start(parent)
File "c:\acmedata\virtualenv\bi\lib\site-packages\celery\bootsteps.py",
line 370, in start return self.obj.start()
File "c:\acmedata\virtualenv\bi\lib\site-
packages\celery\concurrency\base.py",
line 131, in start self.on_start()
File "c:\acmedata\virtualenv\bi\lib\site-
packages\celery\concurrency\prefork.p
y", line 112, in on_start
**self.options)
File "c:\acmedata\virtualenv\bi\lib\site-packages\billiard\pool.py", line
1007 , in __init__ self._create_worker_process(i)
File "c:\acmedata\virtualenv\bi\lib\site-packages\billiard\pool.py", line
1116, in _create_worker_process w.start()
File "c:\acmedata\virtualenv\bi\lib\site-packages\billiard\process.py",
line 124, in start self._popen = self._Popen(self)
File "c:\acmedata\virtualenv\bi\lib\site-packages\billiard\context.py",
line 383, in _Popen return Popen(process_obj)
File "c:\acmedata\virtualenv\bi\lib\site-
packages\billiard\popen_spawn_win32.py",
line 79, in __init__ reduction.dump(process_obj, to_child)
File "c:\acmedata\virtualenv\bi\lib\site-packages\billiard\reduction.py",
line 99, in dump ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <class 'module'>: attribute lookup
module on builtins failed
(bi) C:\acmedata\bi_solution\acmetelbi>Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\acmedata\virtualenv\bi\lib\site-packages\billiard\spawn.py",
line 165, in spawn_main exitcode = _main(fd)
File "c:\acmedata\virtualenv\bi\lib\site-packages\billiard\spawn.py",
line 207, in _main self = pickle.load(from_parent)
EOFError: Ran out of input
i am scratching my head and unable to understand how to fix this. Please help!
my Code for creating a task in django app.
#task()
def myprinting(self):
print("I am task")
and in settings.py :
Other Celery settings
CELERY_BEAT_SCHEDULE = {
'task-number-one': {
'task': 'accounts.tasks.myprinting',
'schedule': crontab(minute='*/30'),
},
after spending many days in research i have come to conclusion that celery have limitation on windows and if you want to run celery on windows then you must have to run it with gevent command:
python manage.py celery worker -P gevent --loglevel=INFO
and then after running this worker process start the celery beat accordingly to start processing.
I am trying to package a kivy application for Windows, and after following the instructions in the Kivy website for the example TouchTracer app, I get an ImportError: No Module named ConfigParser message when trying to open the .exe file in the dist folder.
I am running Python 2.7.11 and kivy 1.9.1.
Also, while executing the command python -m PyInstaller..., the output includes a line that says:
12612 WARNING: Attempted to add Python module twice with different upper/lowercases: ConfigParser
Below is the traceback printed when attempting to open the .exe file.
Traceback (most recent call last):
File "C:\Users\acasall1\Desktop\TouchApp\demo\touchtracer\main.py", line 22,
in <module>
import kivy
File "c:\users\acasall1\appdata\local\temp\pip-build-21skkd\pyinstaller\PyIns
taller\loader\pyimod03_importers.py", line 389, in load_module
File "c:\python27\lib\site-packages\kivy\__init__.py", line 306, in <module>
from kivy.config import Config
File "c:\users\acasall1\appdata\local\temp\pip-build-21skkd\pyinstaller\PyIns
taller\loader\pyimod03_importers.py", line 389, in load_module
File "c:\python27\lib\site-packages\kivy\config.py", line 284, in <module>
from configparser import RawConfigParser as PythonConfigParser
File "c:\users\acasall1\appdata\local\temp\pip-build-21skkd\pyinstaller\PyIns
taller\loader\pyimod03_importers.py", line 389, in load_module
File "C:\Python27\lib\site-packages\configparser\__init__.py", line 5, in <mo
dule>
from ConfigParser import *
ImportError: No module named ConfigParser
Failed to execute script main
I had the same problem for my kivy application, and I found an ad hoc solution. The error comes from the line "import kivy", so uncomment it and the next line "kivy.require('1.0.6')". There lines are unnecessary if your kivy has proper version.
I've created a completely empty PyDev project (NOT "PyDev Django", just "PyDev"), with this single file in it:
import unittest
class Test(unittest.TestCase):
def testName(self):
print "hello world"
And when I either right-click on the file and select "Run As"->"Python unit test", or press CTRL+F9 and click on "testName", I get this error:
Traceback (most recent call last):
File "C:\Program Files\Brainwy\LiClipse 1.2.0\plugins\org.python.pydev_3.8.0.201409251617\pysrc\runfiles.py", line 201, in <module>
main()
File "C:\Program Files\Brainwy\LiClipse 1.2.0\plugins\org.python.pydev_3.8.0.201409251617\pysrc\runfiles.py", line 26, in main
import pydev_runfiles
File "C:\Program Files\Brainwy\LiClipse 1.2.0\plugins\org.python.pydev_3.8.0.201409251617\pysrc\pydev_runfiles.py", line 5, in <module>
django.setup()
File "C:\Python27\lib\site-packages\django\__init__.py", line 20, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 46, in __getattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 40, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
If I put this in the file:
if __name__ == "__main__":
unittest.main()
and execute it using "Run As"->"Python Run", it works fine, but of course it's inconvenient in case there are many tests in the file.
How do I get PyDev to execute the unit tests without Django?
Solved by updating LiClipse from 1.2.0 to 1.4.0 :)