ModuleNotFoundError: No module named '_posixsubprocess' when creating virtual enviroment
Asked Answered
J

1

6

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?

Judicial answered 30/10, 2018 at 9:21 Comment(0)
S
0
  1. pip uninstall subprocess32.
  2. Use the built-in subprocess module: In your Python code, just import subprocess directly. The built-in module has all the functionality you need.
  3. pip3 install virtualenv or pip3 install virtualenvwrapper.
  4. python3 -m venv my-project-env.
  5. And it should be activated on virtualenv in source my-project-env/bin/activate
Stagehand answered 18/8, 2024 at 15:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.