Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating python virtualenv keep showing error of syntax

After a successful installation of virtualenv on centos7

pip install virtualenv

while creating new virtualenv it keeps showing below mentioned error even if I am checking

virtualenv --version

This also shows the same error.

Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 7, in <module>
    from virtualenv.__main__ import run_with_catch
  File "/usr/lib/python2.7/site-packages/virtualenv/__init__.py", line 3, in <module>
    from .run import cli_run
  File "/usr/lib/python2.7/site-packages/virtualenv/run/__init__.py", line 12, in <module>
    from .plugin.activators import ActivationSelector
  File "/usr/lib/python2.7/site-packages/virtualenv/run/plugin/activators.py", line 6, in <module>
    from .base import ComponentBuilder
  File "/usr/lib/python2.7/site-packages/virtualenv/run/plugin/base.py", line 9, in <module>
    from importlib_metadata import entry_points
  File "/usr/lib/python2.7/site-packages/importlib_metadata/__init__.py", line 9, in <module>
    import zipp
  File "/usr/lib/python2.7/site-packages/zipp.py", line 153
SyntaxError: Non-ASCII character '\xe2' in file /usr/lib/python2.7/site-packages/zipp.py on line 154, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

I tried to uninstall and re-install it again but so far no luck.

like image 415
mehulJ Avatar asked Feb 06 '26 20:02

mehulJ


1 Answers

You're using Python 2.7 (which is end-of-life) with a version of Virtualenv that doesn't support Python 2.7.

In order of preference,

  • stop using Python 2.7 and use Python 3.x (currently 3.8) instead
  • or install an older version of Virtualenv (e.g. pip install "virtualenv<20.0", or whatever major version of Virtualenv ends up working for you).
like image 95
AKX Avatar answered Feb 09 '26 12:02

AKX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!