简体   繁体   中英

python3 create virtualenv found error "ModuleNotFoundError: No module named '_ctypes'"

I have install python2.7 and python3.9 in ubuntu. Using python2.7, I can create virtualenv correctly. But using python3.9, It has error as following:

Complete output from command /home/ptxc/test/bin/python3 - setuptools pkg_resources pip wheel:
  Traceback (most recent call last):
  File "<stdin>", line 7, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/__init__.py", line 16, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/vcs/subversion.py", line 9, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/index.py", line 30, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/wheel.py", line 32, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/pep425tags.py", line 9, in <module>
  File "/usr/local/lib/python3.9/ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
...Installing setuptools, pkg_resources, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 2363, in <module>
    main()
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 709, in main
    create_environment(home_dir,
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 984, in create_environment
    install_wheel(
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 918, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 810, in call_subprocess
    raise OSError(
OSError: Command /home/ptxc/test/bin/python3 - setuptools pkg_resources pip wheel failed with error code 1

I try to install libffi-dev, but it has errors: libffi-dev: depends: libffi6 (= 3.2.1-8) but 3.2.1-4kord is being install python-setuptools: depends: python-pkg-resources (= 39.0.1-2) but 20.7.0-1kord is being install

the question is answered. It is version problem. python3 has been set to link python3.5,which is not python3.9. #sudo unlink /usr/bin/python3 #sudo ln -s /usr/local/python3.9/bin/python3 /usr/bin/python3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM