ModuleNotFoundError: No module named '_posixsubprocess' when creating virtual enviroment - virtualenv

i'm trying to set a virtual enviroment with:
$ python3 -m venv cv2
But when trying it, i'm getting this exception:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/lib/python3.6/venv/__init__.py", line 10, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
import subprocess, tempfile, os.path, re, pwd, grp, os, time
File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
Original exception was:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/lib/python3.6/venv/__init__.py", line 10, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
I've trying reinstalling subprocess32, but i haven't solved anything. I'm using Python 3.6.3 Anaconda on Ubuntu 18.04.1 LTS.
Any suggestions?

Related

Python Imports Keep Failing

I recently wrote a package which is on 1.2.9 but when trying to import it using pip install rolimons Python tries to import 1.2.9 which fails and moves on until version 1.1.3 which is the only version that doesn't error out.
Here is the error:
ERROR: Command errored out with exit status 1:
command: /home/runner/rolimonspy-test/venv/bin/python3 /home/runner/rolimonspy-test/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp89bhulpc
cwd: /tmp/pip-install-baj2a_r_/rolimons_41a3df9c7f414766a57996a21dc8cd26
Complete output (16 lines):
Traceback (most recent call last):
File "/home/runner/rolimonspy-test/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 280, in <module>
main()
File "/home/runner/rolimonspy-test/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/runner/rolimonspy-test/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 133, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/tmp/pip-build-env-029qi198/overlay/lib/python3.8/site-packages/poetry/core/masonry/api.py", line 41, in prepare_metadata_for_build_wheel
builder = WheelBuilder(poetry)
File "/tmp/pip-build-env-029qi198/overlay/lib/python3.8/site-packages/poetry/core/masonry/builders/wheel.py", line 56, in __init__
super().__init__(poetry, executable=executable)
File "/tmp/pip-build-env-029qi198/overlay/lib/python3.8/site-packages/poetry/core/masonry/builders/builder.py", line 83, in __init__
self._module = Module(
File "/tmp/pip-build-env-029qi198/overlay/lib/python3.8/site-packages/poetry/core/masonry/utils/module.py", line 69, in __init__
raise ModuleOrPackageNotFound(
poetry.core.masonry.utils.module.ModuleOrPackageNotFound: No file/folder found for package python-template
More information about the structure and package here:

AttributeError: module 'pyspark.sql.utils' has no attribute 'convert_exception'

Hi i have an issue with deltalake im trying to import
from delta import *
but i got the following error
anyone has any idea how to solve it please share it thanks in advance
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/delta/__init__.py", line 17, in <module>
from delta.tables import DeltaTable
File "/usr/local/lib/python3.7/dist-packages/delta/tables.py", line 17, in <module>
import delta.exceptions # noqa: F401; pylint: disable=unused-variable
File "/usr/local/lib/python3.7/dist-packages/delta/exceptions.py", line 152, in <module>
_patch_convert_exception()
File "/usr/local/lib/python3.7/dist-packages/delta/exceptions.py", line 140, in _patch_convert_exception
convert_sql_exception = utils.convert_exception
AttributeError: module 'pyspark.sql.utils' has no attribute 'convert_exception'
>>> from delta import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/delta/__init__.py", line 17, in <module>
from delta.tables import DeltaTable
File "/usr/local/lib/python3.7/dist-packages/delta/tables.py", line 17, in <module>
import delta.exceptions # noqa: F401; pylint: disable=unused-variable
File "/usr/local/lib/python3.7/dist-packages/delta/exceptions.py", line 152, in <module>
_patch_convert_exception()
File "/usr/local/lib/python3.7/dist-packages/delta/exceptions.py", line 140, in _patch_convert_exception
convert_sql_exception = utils.convert_exception
AttributeError: module 'pyspark.sql.utils' has no attribute 'convert_exception'
I had the same problem, I used the delta version 0.6.0 and work!!!
I had the same the issue in Glue jupyter notebook. Then I added following before I start the session:
%glue_version 3.0 %additional_python_modules graphframes==0.6
%extra_jars s3://s3-path/graphframes.jar,s3://s3-path/delta-core_2.12-1.0.0.jar
%extra_py_files s3://s3-path/graphframes.jar,s3://s3-path/delta-core_2.12-1.0.0.jar

Python Keyerror 'sapi5', cant understand the error

One question of this type is previously asked but is not very helpful. I am using version Python3.8 in Windows 10 OS. I am getting an error, KeyError: 'sapi5'. dont know why this error is occurring. Please have a look at the below code given . My code is-
import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices', voices[0].id)
The Error is quite big. can anyone help me?
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError: 'sapi5'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
from comtypes.gen import SpeechLib # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\gen\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'ctypes.c_long'>, <class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.automation.tagVARIANT'>, <class 'ctypes.c_long'>, <class 'ctypes.c_long'>), 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "g:/saurav/Assistant/VA/MyAssistant.py", line 9, in <module>
engine = pyttsx3.init('sapi5')
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in <module>
engine = comtypes.client.CreateObject("SAPI.SpVoice")
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
return _manage(obj, clsid, interface=interface)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
mod = GetModule(tlib)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 110, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 184, in _CreateWrapper
mod = _my_import(fullname)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 24, in _my_import
return __import__(fullname, globals(), locals(), ['DUMMY'])
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 140, in <module>
ISpeechRecoGrammar._methods_ = [
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\__init__.py", line 329, in __setattr__
self._make_methods(value)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\__init__.py", line 698, in _make_methods
prototype = WINFUNCTYPE(restype, *argtypes)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 125, in WINFUNCTYPE
class WinFunctionType(_CFuncPtr):
TypeError: item 2 in _argtypes_ passes a union by value, which is unsupported.
first uninstall pyttsx3 using following command
pip uninstall pyttsx3
Then install pyttsx3 version 2.6 using following command
pip install pyttsx3==2.6

Python errors with telnetlib

I have multiple errors with python's library telnetlib.
When I use it from the repl, here is the code I enter:
import telnetlib
telnetlib.Telnet("<an_ip>", <a_port>) as tn:
write("SYST:BEEP")
It retrurns the following error:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/local/lib/python3.6/telnetlib.py", line 287, in write
if IAC in buffer:
TypeError: 'in <string>' requires string as left operand, not bytes
Now, something which is strange is when I execute the following script:
import telnetlib
def beep(tn):
"""Beep the pulse generator."""
tn.write("SYST:BEEP\n")
# Main for test purpose
if __name__ == "__main__":
with telnetlib.Telnet("<ip>", <port>) as tn:
beep(tn)
I have the following error and I have it each time I import telnetlib...
raceback (most recent call last):
File "test.py", line 1, in <module>
import telnetlib
File "/usr/lib/python3.7/telnetlib.py", line 37, in <module>
import socket
File "/usr/lib/python3.7/socket.py", line 53, in <module>
from enum import IntEnum, IntFlag
File "/usr/lib/python3.7/enum.py", line 2, in <module>
from types import MappingProxyType, DynamicClassAttribute
File "/home/vpecatte/dev/soft/soft/types.py", line 1, in <module>
from typing import *
File "/usr/lib/python3.7/typing.py", line 28, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/usr/lib/python3.7/re.py", line 143, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
if not enabled():
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
import re
File "/usr/lib/python3.7/re.py", line 122, in <module>
import enum
File "/usr/lib/python3.7/enum.py", line 2, in <module>
from types import MappingProxyType, DynamicClassAttribute
File "/home/vpecatte/dev/soft/soft/types.py", line 1, in <module>
from typing import *
File "/usr/lib/python3.7/typing.py", line 31, in <module>
from types import WrapperDescriptorType, MethodWrapperType, MethodDescriptorType
ImportError: cannot import name 'WrapperDescriptorType' from 'types' (/home/vpecatte/dev/soft/soft/types.py)
Original exception was:
Traceback (most recent call last):
File "pulse_generator.py", line 1, in <module>
import telnetlib
File "/usr/lib/python3.7/telnetlib.py", line 37, in <module>
import socket
File "/usr/lib/python3.7/socket.py", line 53, in <module>
from enum import IntEnum, IntFlag
File "/usr/lib/python3.7/enum.py", line 2, in <module>
from types import MappingProxyType, DynamicClassAttribute
File "/home/vpecatte/dev/soft/soft/types.py", line 1, in <module>
from typing import *
File "/usr/lib/python3.7/typing.py", line 28, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/usr/lib/python3.7/re.py", line 143, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
I use python v3.7.5. I replaced correct informations by , .
Thank you for your help.
Looks like you have installed your own types module in /home/vpecatte/dev/soft/soft/types.py which conflicts with the Python built-in types module. The best solution is probably to rename that types module.

Cannot ennable plugin in gedit

I can see many plugins in "Plugin" tab, but I cannot enable or disable any one of them. If I click to enable/disable, Gedit will disappear right away!!: Here is the output from terminal:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site.py", line 548, in <module>
main()
File "/usr/local/lib/python2.7/site.py", line 530, in main
known_paths = addusersitepackages(known_paths)
File "/usr/local/lib/python2.7/site.py", line 266, in addusersitepackages
user_site = getusersitepackages()
File "/usr/local/lib/python2.7/site.py", line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/local/lib/python2.7/site.py", line 231, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/local/lib/python2.7/sysconfig.py", line 516, in get_config_var
return get_config_vars().get(name)
File "/usr/local/lib/python2.7/sysconfig.py", line 449, in get_config_vars
import re
File "/usr/local/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/usr/local/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/usr/local/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/usr/local/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Please help me! many thanks.
Ubuntu Release 12.04 (precise) 32-bit
Kernel Linux 3.5.0-39-generic
GNOME 3.4.2
I think the problem is because you use gnome 3 and gedit 2.