RetroParody
RetroParody

Reputation: 1

Python virtualenv issue

I was having a issue for virtualenv and was trying to make a environment ,my terminal was showing

zsh: command not found: virtualenv

and so I looked for a article about this issue and it said to do this command

sudo /usr/bin/easy_install virtualenv

and I got allot of error issues,

sudo /usr/bin/easy_install virtualenv

Password:
Searching for virtualenv
Reading https://pypi.org/simple/virtualenv/
Downloading https://files.pythonhosted.org/packages/ac/8a/05e8d8a3ac88a3c4ebec1fe2b1b4730e6e6ebdddb52cfd6cea6803de4624/virtualenv-20.10.0-py2.py3-none-any.whl#sha256=4b02e52a624336eece99c96e3ab7111f469c24ba226a53ec474e8e787b365814
Best match: virtualenv 20.10.0
Processing virtualenv-20.10.0-py2.py3-none-any.whl
Installing virtualenv-20.10.0-py2.py3-none-any.whl to /Library/Python/2.7/site-packages
writing requirements to /Library/Python/2.7/site-packages/virtualenv-20.10.0-py2.7.egg/EGG-INFO/requires.txt
Adding virtualenv 20.10.0 to easy-install.pth file
Installing virtualenv script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/virtualenv-20.10.0-py2.7.egg
Processing dependencies for virtualenv
Searching for platformdirs<3,>=2
Reading https://pypi.org/simple/platformdirs/
Downloading https://files.pythonhosted.org/packages/4b/96/d70b9462671fbeaacba4639ff866fb4e9e558580853fc5d6e698d0371ad4/platformdirs-2.4.0.tar.gz#sha256=367a5e80b3d04d2428ffa76d33f124cf11e8fff2acdaa9b43d545f5c7d661ef2
Best match: platformdirs 2.4.0
Processing platformdirs-2.4.0.tar.gz
Writing /tmp/easy_install-KWRbQe/platformdirs-2.4.0/setup.cfg
Running platformdirs-2.4.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-KWRbQe/platformdirs-2.4.0/egg-dist-tmp-EYRfYA
  File "build/bdist.macosx-11.6-x86_64/egg/platformdirs/macos.py", line 15
    def user_data_dir(self) -> str:
                            ^
SyntaxError: invalid syntax

  File "build/bdist.macosx-11.6-x86_64/egg/platformdirs/unix.py", line 13
    def getuid() -> int:
                 ^
SyntaxError: invalid syntax

  File "build/bdist.macosx-11.6-x86_64/egg/platformdirs/__init__.py", line 18
    def _set_platform_dir_class() -> Type[PlatformDirsABC]:
                                  ^
SyntaxError: invalid syntax

  File "build/bdist.macosx-11.6-x86_64/egg/platformdirs/api.py", line 18
    appname: Optional[str] = None,
           ^
SyntaxError: invalid syntax

  File "build/bdist.macosx-11.6-x86_64/egg/platformdirs/android.py", line 17
    def user_data_dir(self) -> str:
                            ^
SyntaxError: invalid syntax

  File "build/bdist.macosx-11.6-x86_64/egg/platformdirs/windows.py", line 20
    def user_data_dir(self) -> str:
                            ^
SyntaxError: invalid syntax

  File "build/bdist.macosx-11.6-x86_64/egg/platformdirs/__main__.py", line 16
    def main() -> None:
               ^
SyntaxError: invalid syntax

Copying platformdirs-0.0.0-py2.7.egg to /Library/Python/2.7/site-packages
Adding platformdirs 0.0.0 to easy-install.pth file

Installed /Library/Python/2.7/site-packages/platformdirs-0.0.0-py2.7.egg
error: The 'platformdirs<3,>=2' distribution was not found and is required by virtualenv

I decided to make a environment and see what happens

virtualenv environment
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
    @_call_aside
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
    f(*args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'platformdirs<3,>=2' distribution was not found and is required by virtualenv

I use 3.10.0 but over here in the error I think it tried to install to version 2.7

I did

pip3 uninstall virtualenv

pip3 install virtualenv

, and tried to make a new environment. Still the same error occurs. I think I messed up 2.7. What should I do?! I am using MacOS if it helps

Upvotes: 0

Views: 135

Answers (2)

OneCricketeer
OneCricketeer

Reputation: 191671

zsh: command not found: virtualenv

sudo is not a fix for this. Figuring out what is wrong with the current user's PATH, is the solution here...

However, Python3 comes with venv rather than needing to install anything else

python3 -m venv my-env
source my-env/bin/activate

https://docs.python.org/3/library/venv.html

Upvotes: 1

RetroParody
RetroParody

Reputation: 1

So it was not possible to do virtualenv environment But python3 -m venv environment I am not sure why it is like this but once I ran the command it seems that it made it into a environment

Upvotes: 0

Related Questions