question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PYTHONHOME issue?

See original GitHub issue

I had cocotb running in our work environment only last week or so, but something has started to cause the following issue.

I’m on CentOS 7 and the SIM=xcelium

The simple_dff example appears to die the same way, so here’s the output from that:

        module worklib.dff:sv
                errors: 0, warnings: 0
     -.--ns INFO     cocotb.gpi                         ..mbed/gpi_embed.cpp:74   in set_program_name_in_venv        Did not detect Python virtual environment. Using system-wide Python interpreter
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fa44e62ee00 (most recent call first):
ImportError: No module named site
xmelab: *F,INTERR: INTERNAL EXCEPTION

Some output from cocotb-config:

$ cocotb-config --version
1.4.0rc1
$ cocotb-config --python-bin
/usr/bin/python3
$ cocotb-config --prefix
/usr/local/lib64/python3.6/site-packages

Running the following (as per Makefile.inc’s way of calculating PYTHONHOME):

$ /usr/bin/python3 -c 'from distutils.sysconfig import get_config_var; print(get_config_var("prefix"))'
/usr

An interesting observation (I think anyway?) is if I set PYTHONHOME to /usr/local under which the site-packages/cocotb is really located (as per the cocotb-config output), I see the same crash.

$ PYTHONHOME=/usr /usr/bin/python3
Python 3.6.8 (default, Apr  2 2020, 13:34:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

$ PYTHONHOME=/usr/local /usr/bin/python3
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f4ce0135740 (most recent call first):
Aborted

Any ideas? I’m quite certain this worked only a week ago, I just updated to the latest cocotb, but I’m not ruling out something changing on my system, too.

Thanks for any pointers, and great job with cocotb so far all!!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:39 (29 by maintainers)

github_iconTop GitHub Comments

2reactions
thasticommented, Apr 14, 2021

Yes, I will attempt to recreate the failure mode. To make it clear: Things started working after removing the hacks that injected libpython via LD_LIBRARY_PATH. These used to work for older versions of Xcelium, but stopped working with Xcelium 20.

Since I was recently able to get the python development packages installed on the systems in question, I do not need to perform these hacks anymore and cocotb works as-is, even in a venv.

1reaction
imphilcommented, Jun 25, 2020

The probably easiest option for a bisect is to clone the cocotb repository, and then install with pip from the repository.

git clone https://github.com/cocotb/cocotb
cd cocotb
pip install .

Then you can either use git bisect or just manually go back to a commit a couple weeks back. Re-run pip install . after you’ve checked out a different commit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue 6060: PYTHONHOME should be more flexible (and ...
The PYTHONHOME variable does not allow complete control over making a Python installation find its own libs because "lib/pythonX.
Read more >
Troubleshooting - IBM
This error is generally caused by setting the PYTHONHOME environment variable to a conflicting location. Try to set the PYTHONHOME ...
Read more >
Working with Matplotlib on OSX
PYTHONHOME and Jupyter; PYTHONHOME Script ... This can result in issues for a Python installation not build as a framework and may also...
Read more >
Apache Won't Start, Encodings cannot be found - Stack Overflow
Yes, this error is reported when PYTHONHOME does not have a valid Python installation.
Read more >
Mac/Python 3 issue with -m option (#20305) - GitLab
I am confused, why are we opening this issue? The PYTHONHOME issue has nothing to do with this. So long as the -l...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found