How to solve ImportError: cannot import name 'ProcessPoolExecutor' - python

I'm getting this error when trying to using polyglot library for the first time.
from polyglot.text import Text, Word
word = Text("Preprocessing is an essential step.").words[0]
print(word.morphemes)
here is the full error message.
Traceback (most recent call last):
File "/home/adeesha/PycharmProjects/theme_recomend/plyglot.py", line 2, in <module>
from polyglot.text import Text, Word
File "/usr/local/lib/python3.5/dist-packages/polyglot-16.7.4-py3.5.egg/polyglot/__init__.py", line 12, in <module>
from .base import Sequence, TokenSequence
File "/usr/local/lib/python3.5/dist-packages/polyglot-16.7.4-py3.5.egg/polyglot/base.py", line 9, in <module>
from concurrent.futures import ProcessPoolExecutor, as_completed
ImportError: cannot import name 'ProcessPoolExecutor'
the version of Python 3.5.2
how I gonna solve this problem?

Related

I need help using ctypes on jython

I want to use libxmp.
I used:
import sys
sys.path.append('/usr/local/lib/python3.8/dist-packages')
which directly locate to libxmp
from libxmp import XMPFiles, consts
from libxmp.utils import file_to_dict
upper code box is the import part
I faced this problem:
Traceback (most recent call last):
File "/home/webprime/jython/jython/jython.py", line 5, in <module>
from libxmp import XMPFiles, consts
File "/usr/local/lib/python3.8/dist-packages/libxmp/__init__.py", line 37, in <module>
from ctypes import util
ImportError: cannot import name util
it works on Python 3.

Unable to import torch.distributed.rpc

I was trying to run the RPC rnn example from the following link - https://github.com/pytorch/examples/tree/master/distributed/rpc/rnn
but I am unable to import RPC module of the torch.distributed and getting the following error.
Traceback (most recent call last):
File ".\main.py", line 6, in <module>
import torch.distributed.rpc as rpc
File "C:\Users\Public\Anaconda\lib\site-packages\torch\distributed\rpc\__init__.py", line 9, in <module>
from . import backend_registry
File "C:\Users\Public\Anaconda\lib\site-packages\torch\distributed\rpc\backend_registry.py", line 8, in <module>
import torch.distributed.distributed_c10d as dc10d
File "C:\Users\Public\Anaconda\lib\site-packages\torch\distributed\distributed_c10d.py", line 9, in <module>
from .rendezvous import rendezvous, register_rendezvous_handler # noqa: F401
File "C:\Users\Public\Anaconda\lib\site-packages\torch\distributed\rendezvous.py", line 9, in <module>
from . import FileStore, TCPStore
ImportError: cannot import name 'FileStore' from 'torch.distributed' (C:\Users\Public\Anaconda\lib\site-packages\torch\distributed\__init__.py)
Torch Version:
torch 1.4.0+cpu
torchvision 0.5.0+cpu
PyTorch Distributed package does not support Windows yet. Requests for this feature is tracked here: https://github.com/pytorch/pytorch/issues/37068

How to specify the process in python pwntools?

Cant set the process in Python 2.7.17 pwntools.
Source code:
from pwn import *
s=process('/root/Dokumente/Scripts/example_program')
I tried from pwn import *:
root#bitpc:~# python pwn.py
Traceback (most recent call last):
File "pwn.py", line 1, in <module>
from pwn import *
File "/root/pwn.py", line 2, in <module>
s=process('/root/Dokumente/Scripts/example_program')
NameError: name 'process' is not defined
That was not working. Then i imported process directly:
root#bitpc:~# python pwn.py
Traceback (most recent call last):
File "pwn.py", line 1, in <module>
from pwn import process
File "/root/pwn.py", line 1, in <module>
from pwn import process
ImportError: cannot import name process
I got an import error. How to fix this?
It seems that your exploit script's name is pwn.py. rename it to some other name such as exp.py. otherwise python will try to import things in your pwn.py instead of importing things from pwntools.

from requests import Session as OriginalSession ImportError: cannot import name 'Session'

I don't understand the error I get and searching online was not helpful.
Traceback (most recent call last):
File "/Users/<path>/file.py", line 1, in <module>
from coinmarketcap import Market
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/coinmarketcap/__init__.py", line 10, in <module>
from .core import Market
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/coinmarketcap/core.py", line 8, in <module>
import requests_cache
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests_cache/__init__.py", line 28, in <module>
from .core import(
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests_cache/core.py", line 14, in <module>
from requests import Session as OriginalSession
ImportError: cannot import name 'Session'
It seems to be generated from the very first line where the import and code is the following:
from coinmarketcap import Market
cmc = Market()
coins = cmc.ticker(limit=15) # assumes Dash in top 15.
print(coins)
Not sure if it helps but I had similar issue with import - turned out I have created requests.py file and imported stuff from there. It caused namespace clash as other libraries I used in the project were dependent on built-in requests module.

Test framework quits unexpectedly - IntelliJ python plugin

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.

Categories