ray
ray copied to clipboard
[Bug] `import ray` fails with `_Py_GetArgcArgv` symbol not found on macOS with Python 3.8.9
What happened + What you expected to happen
I am able to reproduce on a macOS instance in CircleCI that import ray
gives the following error when I install and import it in a virtualenv
with Python 3.8.9:
python -c "import ray"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/distiller/venv/lib/python3.8/site-packages/ray/__init__.py", line 115, in <module>
import ray._raylet # noqa: E402
File "python/ray/_raylet.pyx", line 16, in init ray._raylet
ImportError: dlopen(/Users/distiller/venv/lib/python3.8/site-packages/ray/thirdparty_files/setproctitle.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_Py_GetArgcArgv'
Oddly, the error does not occur if I first invoke import setproctitle
before importing ray
.
Versions / Dependencies
- macOS 12.3.1
- Python 3.8.9
-
ray==1.13.0
- Xcode 13.4.1
Reproduction script
CircleCI config.yml
script:
version: 2.1
jobs:
import-ray:
macos:
xcode: 13.4.1
steps:
- checkout
- run:
name: Install ray and setproctitle in virtualenv
command: |
virtualenv -p python3.8 ~/venv
source ~/venv/bin/activate
pip install ray setproctitle
- run:
name: Print OS, Python, and Python package versions
command: |
source ~/venv/bin/activate
sw_vers
python --version
pip freeze --all
- run:
# this succeeds
name: Check importing setproctitle and then importing ray works
command: |
source ~/venv/bin/activate
python -c "import setproctitle; import ray"
- run:
# this fails
name: Check importing ray by itself works
command: |
source ~/venv/bin/activate
python -c "import ray"
workflows:
sample:
jobs:
- import-ray
Issue Severity
No response
pip install ray setproctitle
if you don't download setproctitle
, does it still happen?
Yup, it still does.
Can you also try using conda and see if this is still reproducible?
Not that I recommend you to use conda, but I'd like to know if this is virtual env related issue (I feel like I've seen a similar issue before)
Interesting—conda works.
For reference: The CircleCI config.yml
script I used to test this:
version: 2.1
jobs:
import-ray:
macos:
xcode: 13.4.1
steps:
- checkout
- run:
name: Install conda
command: |
brew install --cask anaconda
- run:
name: Init conda
# required for `conda activate` to work and places `conda` in the PATH
command: |
/usr/local/anaconda3/bin/conda init bash
- run:
name: Install ray
# should use python=3.8.9 to match the Python version in the virtualenv example,
# but conda doesn't have python 3.8.9
command: |
conda create --name my_env python=3.8.8 --yes
conda activate my_env
pip install ray
- run:
name: Print OS, Python, and Python package versions
command: |
conda activate my_env
sw_vers
python --version
pip freeze --all
- run:
name: Check importing ray by itself works
command: |
conda activate my_env
python -c "import ray"
workflows:
sample:
jobs:
- import-ray
I think Ray is probably not working well with virtualenv. I feel like I've seen this issue before. We will take a look at this issue later.
cc @scv119
Per Triage sync: same as https://github.com/ray-project/ray/issues/22408