Test framework quits unexpectedly - IntelliJ python plugin - python

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.

Related

anti-SMASH antismash --check-prereqs TRACEBACK and IMPORT ERRORS

I am now trying if my recently installed anti-SMASH would work. However, the following lines appear as I type antismash --check-prereqs:
Traceback (most recent call last):
File "/home/promt/asenv/bin/antismash", line 5, in
from antismash.main import entrypoint
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/init.py", line 12, in
from antismash.main import run_antismash, get_detection_modules,
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/main.py", line 31, in
from antismash.common import logs, record_processing, serialiser
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/common/record_processing.py", line 19, in
from antismash.common.secmet import Record
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/common/secmet/init.py", line 11, in
from .record import Record
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/common/secmet/record.py", line 25, in
from .features import (
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/common/secmet/features/init.py", line 6, in
from .antismash_domain import AntismashDomain
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/common/secmet/features/antismash_domain.py", line 10, in
from .domain import Domain, generate_protein_location_from_qualifiers
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/common/secmet/features/domain.py", line 13, in
from .feature import Feature, FeatureLocation, Location
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/common/secmet/features/feature.py", line 13, in
from antismash.common.secmet.locations import (
File "/home/promt/asenv/lib/python3.9/site-packages/antismash/common/secmet/locations.py", line 9, in
from Bio.SeqFeature import (
ImportError: cannot import name 'AbstractPosition' from 'Bio.SeqFeature' (/home/promt/asenv/lib/python3.9/site-packages/Bio/SeqFeature.py)
How can I fix it? Thanks!
I also typed the following but to no avail:
antismash --help
antismash --help-showall

AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely due to a circular import)

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.

Python importing messages module not working

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'

Simple code for create a thread in Python 2.7

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.

Cannot `import smtplib`

When ever I try to import smtplib in the Python interpreter, I get this error:
ImportError: cannot import name fix_eols
How can I fix this?
Edit:
Here is the full stack trace:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 46, in <module>
import email.utils
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 32, in <module>
from email._parseaddr import quote
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/_parseaddr.py", line 16, in <module>
import time, calendar
File "/Users/aaronblock/Documents/programming/scripts/calendar.py", line 7, in <module>
File "/usr/local/lib/python2.7/site-packages/apiclient/__init__.py", line 19, in <module>
from googleapiclient import discovery
File "/usr/local/lib/python2.7/site-packages/googleapiclient/discovery.py", line 38, in <module>
from email.generator import Generator
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/generator.py", line 15, in <module>
from email.header import Header
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/header.py", line 16, in <module>
import email.quoprimime
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/quoprimime.py", line 49, in <module>
from email.utils import fix_eols
ImportError: cannot import name fix_eols
Just to point out how to detect this kinds of errors (since it does happen from time to time):
Pay attention to the stacktrace. In this example, the problem can be seen in the line:
File "/Users/aaronblock/Documents/programming/scripts/calendar.py", line 7, in <module>
which certainly indicates wrong file being imported when we're trying to import a system-wide library.
I had a file called "calendar.py" which messes up my Python environment because smtplib needs calendar.py in order to work. Deleting calendar.py solved my problem.

Categories