I'm new to Python and I'm trying to do a simple thread as follows.
import threading
def func(x):
print x
t1 = threading.Thread(target=func,args=("Hello",));
t1.start();
Then I got following error:
Traceback (most recent call last):
File "ex2.py", line 1, in <module>
import threading
File "/Users/treinetic-macbook/Desktop/threading.py", line 2, in <module>
File "/Library/Python/2.7/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/Library/Python/2.7/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Python/2.7/site-packages/urllib3/connectionpool.py", line 3, in <module>
import logging
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 207, in <module>
_lock = threading.RLock()
AttributeError: 'module' object has no attribute 'RLock'
can someone help me to understand this error?
/Users/treinetic-macbook/Desktop/threading.py is being imported because it's on your path somewhere. This is most likely not correct, try renaming that file and removing any threading.pyc file in your local dir.
Related
I wrote imports as usual, but it is wrong. I searched and did not find a mistake like mine, please help. The file name is main.py .
Traceback (most recent call last):
File "/app/main.py", line 2, in <module>
from telethon import TelegramClient, Button, events, version
File "/usr/local/lib/python3.9/site-packages/telethon/__init__.py", line 1, in <module>
from .client.telegramclient import TelegramClient
File "/usr/local/lib/python3.9/site-packages/telethon/client/__init__.py", line 12, in <module>
from .telegrambaseclient import TelegramBaseClient
File "/usr/local/lib/python3.9/site-packages/telethon/client/telegrambaseclient.py", line 3, in <module>
import asyncio
File "/usr/local/lib/python3.9/asyncio/__init__.py", line 8, in <module>
from .base_events import *
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 18, in <module>
import concurrent.futures
File "/usr/local/lib/python3.9/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 7, in <module>
import logging
File "/usr/local/lib/python3.9/logging/__init__.py", line 28, in <module>
from string import Template
File "/app/string.py", line 7, in <module>
from telethon import TelegramClient, events
File "/usr/local/lib/python3.9/site-packages/telethon/events/__init__.py", line 1, in <module>
from .raw import Raw
File "/usr/local/lib/python3.9/site-packages/telethon/events/raw.py", line 1, in <module>
from .common import EventBuilder
File "/usr/local/lib/python3.9/site-packages/telethon/events/common.py", line 5, in <module>
from .. import utils
File "/usr/local/lib/python3.9/site-packages/telethon/utils.py", line 22, in <module>
from .extensions import markdown, html
File "/usr/local/lib/python3.9/site-packages/telethon/extensions/markdown.py", line 9, in <module>
from ..helpers import add_surrogate, del_surrogate, within_surrogate, strip_text
File "/usr/local/lib/python3.9/site-packages/telethon/helpers.py", line 20, in <module>
_log = logging.getLogger(__name__)
AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely due to a circular import)
I had similar issue, my python file was called token.py. Once I renamed it into something else the problem went away.
I am trying to parse some protobuf messages and importing the messages module. However getting below error. Not sure what I am missing.
Please advise.
>>> import messages
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/messages/__init__.py", line 7, in <module>
from .api import send
File "/usr/local/lib/python3.8/dist-packages/messages/api.py", line 3, in <module>
from .email_ import Email
File "/usr/local/lib/python3.8/dist-packages/messages/email_.py", line 15, in <module>
from ._config import check_config_file
File "/usr/local/lib/python3.8/dist-packages/messages/_config.py", line 12, in <module>
import jsonconfig
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/__init__.py", line 7, in <module>
from .core import Config
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/core.py", line 11, in <module>
from .jsonutils import to_json_file, from_json_file
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/jsonutils.py", line 29, in <module>
to_json = box._to_json
AttributeError: module 'box' has no attribute '_to_json'
I'm having some issues running checkov, I'm not familiar with python libraries, anyone can give me some hints?
This is working fine in some machines but not in this one in particular...
Running in CentOS:
$ checkov --directory cdk.out
Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in <module>
from checkov.main import run
File "/usr/local/lib/python3.6/site-packages/checkov/main.py", line 22, in <module>
from checkov.terraform.plan_runner import Runner as tf_plan_runner
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/plan_runner.py", line 11, in <module>
from checkov.terraform.context_parsers.registry import parser_registry
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/context_parsers/__init__.py", line 1, in <module>
from checkov.terraform.context_parsers.parsers import *
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/context_parsers/parsers/provider_context_parser.py", line 1, in <module>
import hcl2
File "/usr/local/lib/python3.6/site-packages/hcl2/__init__.py", line 5, in <module>
from .api import load, loads
File "/usr/local/lib/python3.6/site-packages/hcl2/api.py", line 4, in <module>
from hcl2.parser import hcl2
File "/usr/local/lib/python3.6/site-packages/hcl2/parser.py", line 53, in <module>
hcl2 = Lark_StandAlone(transformer=DictTransformer())
File "/usr/local/lib/python3.6/site-packages/hcl2/lark_parser.py", line 8, in Lark_StandAlone
return Lark._load_from_dict(DATA, MEMO, **kwargs)
AttributeError: type object 'Lark' has no attribute '_load_from_dict'
After upgrading python from 3.6 to 3.8 and reinstalling checkov it worked just fine.
I'm new to python, and I was creating a Bot to discord by PyCharm when suddenly there was this giant error below, I already reinstalled python, tried configuring the PATHs for python 3.7 and 3.6, changed IDE and continues giving this error, can anyone help me figure out what's causing this?
error below:
C:\Users\Pichau\AppData\Local\Programs\Python\Python36\python.exe C:/Users/Pichau/Documents/cursos/programacao/Discord/main.py
Traceback (most recent call last):
File "C:/Users/Pichau/Documents/cursos/programacao/Discord/main.py", line 1, in <module>
import discord
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 28, in <module>
from .user import User
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\user.py", line 27, in <module>
from .utils import snowflake_time
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\utils.py", line 31, in <module>
import asyncio
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\asyncio\__init__.py", line 21, in <module>
from .base_events import *
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 17, in <module>
import concurrent.futures
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\_base.py", line 7, in <module>
import logging
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\logging\__init__.py", line 26, in <module>
import sys, os, time, io, traceback, warnings, weakref, collections
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\tokenize.py", line 41, in <module>
__all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding",
AttributeError: module 'token' has no attribute '__all__'
Process finished with exit code 1
Image of error
I would check the code, unless it won’t let you, then you should probably put the code in notepad, and save it then delete the file, and try again. It probably is a computer error more then a coding error.
I'm having a big problem with the testing framework in IntelliJ using with the python plugin.
When I launch my tests, written using unittest, the tests fail with an import error in the _jb_test_runner file.
I surfed the net for a while, but didn't get a useful solution. See the stacktrace below:
/usr/bin/python3.5 /home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py --path /home/davide/Scrivania/musical-store/test/types/test_person.py
Testing started at 12.35 ...
Traceback (most recent call last):
File "/home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py", line 4, in <module>
from unittest import main
File "/usr/lib/python3.5/unittest/__init__.py", line 58, in <module>
from .result import TestResult
File "/usr/lib/python3.5/unittest/result.py", line 5, in <module>
import traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
import re, traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Original exception was:
Traceback (most recent call last):
File "/home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py", line 4, in <module>
from unittest import main
File "/usr/lib/python3.5/unittest/__init__.py", line 58, in <module>
from .result import TestResult
File "/usr/lib/python3.5/unittest/result.py", line 5, in <module>
import traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Process finished with exit code 1
The code does not present any syntax error, but the problem started after a refactoring of the whole project I'm working on.
Thanks in advance.