Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cygdb not working with recent virtualenvs #1961

Open
BertrandBordage opened this issue Oct 29, 2017 · 6 comments
Open

Cygdb not working with recent virtualenvs #1961

BertrandBordage opened this issue Oct 29, 2017 · 6 comments

Comments

@BertrandBordage
Copy link
Contributor

In recent Python virtualenvs, there is no activate_this.py file.

Cygdb therefore fails to load:

Reading symbols from python3-dbg...done.
gdb command file: Activating virtualenv: /home/myuser/.virtualenvs/myenv; path_to_activate_this_py: /home/myuser/.virtualenvs/myenv/bin/activate_this.py
Traceback (most recent call last):
  File "<string>", line 8, in <module>
FileNotFoundError: [Errno 2] Aucun fichier ou dossier de ce type: '/home/myuser/.virtualenvs/myenv/bin/activate_this.py'
/tmp/tmpohzn6ela:19: Error in sourced command file:
Error while executing Python code.
@astrojuanlu
Copy link

astrojuanlu commented Dec 19, 2017

Is cygdb supported with python3-dbg at all? If so, the documentation is outdated http://docs.cython.org/en/latest/src/userguide/debugging.html Not sure if that's the cause of this issue though.

@scoder
Copy link
Contributor

scoder commented Mar 31, 2019

To do: find the right way to activate a Py3 venv and do that conditionally in Cygdb.py.

@astrojuanlu
Copy link

Not sure if that's the cause of this issue though.

Answering my old self: this happens for virtual environments created with Python 3 venv or pyenv, see https://stackoverflow.com/a/33637378/554319.

@astrojuanlu
Copy link

For the moment, testing this horrible hack:

            if virtualenv:
                # path_to_activate_this_py = os.path.join(virtualenv, 'bin', 'activate_this.py')
                # print("gdb command file: Activating virtualenv: %s; path_to_activate_this_py: %s" % (
                #     virtualenv, path_to_activate_this_py))
                # with open(path_to_activate_this_py) as f:
                #     exec(f.read(), dict(__file__=path_to_activate_this_py))
                import sys
                sys.path.insert(0, os.path.join(virtualenv, "lib", "python3.7", "site-packages"))

@scoder
Copy link
Contributor

scoder commented Jul 1, 2019

PR welcome that fixes this. Even one that resolves it only for Py3.

@seilis
Copy link

seilis commented Mar 18, 2021

Recently ran into this issue setting up cygdb in an existing environment that uses venv extensively. What's required to push through the fix? The last comments on the PR date from last September.

If some help is needed, I can jump in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants