[UPDATE] This seems to be a problem with the Parallels VM (https://forum.parallels.com/threads/execution-files-located-on-shared-folders-mount-with-exec.352815/). Thanks to all who commented!
I have a strange problem with my virtualenv (on Ubuntu 20.04). I activate my virtualenv as follows.
aravind@vetinari:test_venv$ rm -r venv
aravind@vetinari:test_venv$ python -m venv venv
aravind@vetinari:test_venv$ source venv/bin/activate
I then install an empty package with one script called test_version.py which is also successful.
(venv) aravind@vetinari:test_venv$ python -m pip install -e .
Obtaining file:///media/psf/Home/projects/test_venv
Installing collected packages: test-venv
Attempting uninstall: test-venv
Found existing installation: test-venv 0.0.1.dev0
Not uninstalling test-venv at /media/psf/Home/projects/test_venv, outside environment /media/psf/Home/projects/test_venv/venv
Can't uninstall 'test-venv'. No files were found to uninstall.
Running setup.py develop for test-venv
Successfully installed test-venv
When I run it with the virtualenv python, it runs fine.
(venv) aravind@vetinari:test_venv$ /media/psf/Home/projects/test_venv/venv/bin/python /media/psf/Home/projects/test_venv/venv/bin/test_version.py
3.8.10
However, when I run it as a standalone script, I get this error.
(venv) aravind@vetinari:test_venv$ /media/psf/Home/projects/test_venv/venv/bin/test_version.py
bash: /media/psf/Home/projects/test_venv/venv/bin/test_version.py: /media/psf/Home/projects/test_venv/venv/bin/python: bad interpreter: Invalid argument
Here are the contents of the installed script.
(venv) aravind@vetinari:test_venv$ cat /media/psf/Home/projects/test_venv/venv/bin/test_version.py
#!/media/psf/Home/projects/test_venv/venv/bin/python
# EASY-INSTALL-DEV-SCRIPT: 'test-venv==0.0.1.dev0','test_version.py'
__requires__ = 'test-venv==0.0.1.dev0'
__import__('pkg_resources').require('test-venv==0.0.1.dev0')
__file__ = '/media/psf/Home/projects/test_venv/bin/test_version.py'
with open(__file__) as f:
exec(compile(f.read(), __file__, 'exec'))
Note that the shebang interpreter (media/psf/Home/projects/test_venv/venv/bin/python) in the script is present and it works fine when I execute it with that python but not when I run it as a standalone script.
Here are the contents of the script.
(venv) aravind@vetinari:test_venv$ cat bin/test_version.py
#!/usr/bin/env python
import platform; print(platform.python_version())
and the setup.py.
(venv) aravind@vetinari:test_venv$ cat setup.py
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(name='test_venv',
version='0.0.1dev',
description='Test',
author='Aravind Sundaresan',
maintainer='Aravind Sundaresan',
packages=find_packages(),
scripts=["bin/test_version.py",],
install_requires=[],
zip_safe=False
)
setup.pyand other relevant files to reproduce the problem.#!/media/psf/Home/projects/test_venv/venv/bin/pythonDoes that program exist?straceand watch for the actual syscall that fails.parallelstag for you. Re the running, you're facing a rather nasty issue. Consider creating a new question just for Parallels I guess or simply switch to a different emulator for the quickest fix. Maybe there's even a simple converter somewhere online and if not, check thehistorycommand for your VM, copy-paste files to host and reinstall in a different emulator.