pipenv project working on command line but not in pycharm

已回答

I have a pipenv project that works on the command line, but not in PyCharm. I'm really stuck because I need PyCharm for its debugger integration. PDB is fine, but it's 100x faster to use debugger in PyCharm. I'm sure this is due to some trivial config setting I missed somewhere, but I have not been able to find it. Please help!

Here is the info from the command line

brianbeckman@pop-os  ~/Documents/GitHub/mujoco-py   master v2.0.2.2 ? 
mujoco-py-w-7Ahox1  pipenv graph  ✔  1209  06:20:05
mujoco-py==2.0.2.2
- cffi [required: >=1.10, installed: 1.12.2]
- pycparser [required: Any, installed: 2.19]
- Cython [required: >=0.27.2, installed: 0.29.7]
- glfw [required: >=1.4.0, installed: 1.7.1]
- imageio [required: >=2.1.2, installed: 2.5.0]
- numpy [required: Any, installed: 1.16.2]
- pillow [required: Any, installed: 6.0.0]
- lockfile [required: >=0.12.2, installed: 0.12.2]
- numpy [required: >=1.11, installed: 1.16.2]


Some environment variables that include the word PATH are as follows

brianbeckman@pop-os  ~/Documents/GitHub/mujoco-py   master v2.0.2.2 ? 
mujoco-py-w-7Ahox1  set | grep PATH  ✔  1211  06:21:33

LD_LIBRARY_PATH=/home/brianbeckman/.mujoco/mujoco200/bin:/home/brianbeckman/.mujoco/mjpro150/bin:/usr/local/cuda/lib64:/home/brianbeckman/.mujoco/mujoco200/bin:/home/brianbeckman/.mujoco/mjpro150/bin:/usr/local/cuda/lib64
PATH=/home/brianbeckman/.local/share/virtualenvs/mujoco-py-w-7Ahox1/bin:/home/brianbeckman/anaconda3/bin/home/brianbeckman/.pyenv/plugins/pyenv-virtualenv/shims:/home/brianbeckman/.pyenv/shims:/home/brianbeckman/.pyenv/bin:/usr/local/cuda-9.0/bin:/home/brianbeckman/anaconda3/bin/home/brianbeckman/.pyenv/plugins/pyenv-virtualenv/shims:/home/brianbeckman/.pyenv/shims:/home/brianbeckman/.pyenv/bin:/usr/local/cuda-9.0/bin:/home/brianbeckman/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
PIP_PYTHON_PATH=/usr/bin/python3
PYTHONPATH=/usr/lib/tensorflow/lib/python3.6:/usr/lib/tensorflow/lib/python3.6:

 

program works when i run it from command line

 

brianbeckman@pop-os  ~/Documents/GitHub/mujoco-py   master v2.0.2.2 ? 
mujoco-py-w-7Ahox1  python examples/markers_demo.py  ✔  1210  06:20:12
Creating window glfw
Pressed ESC
Quitting.

 

Now, I tried to make PyCharm run configuration and environment variables and pipenv exactly like command line 

 

 

and here is the error that PyCharm gives me

 

PyDev console: starting.
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
import os
os.environ['LD_LIBRARY_PATH'] = '/home/brianbeckman/.mujoco/mjpro150/bin:/home/brianbeckman/.mujoco/mujoco200/bin:$LD_LIBRARY_PATH'
os.environ['LD_PRELOAD'] = '/usr/lib/x86_64-linux-gnu/libGLEW.so'
runfile('/home/brianbeckman/Documents/GitHub/mujoco-py/examples/markers_demo.py', wdir='/home/brianbeckman/Documents/GitHub/mujoco-py/examples')
Import error. Trying to rebuild mujoco_py.
Compiling /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/cymj.pyx because it depends on /home/brianbeckman/.local/share/virtualenvs/mujoco-py-w-7Ahox1/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd.
[1/1] Cythonizing /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/cymj.pyx
running build_ext
building 'mujoco_py.cymj' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py -I/home/brianbeckman/.mujoco/mujoco200/include -I/home/brianbeckman/.local/share/virtualenvs/mujoco-py-w-7Ahox1/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -I/home/brianbeckman/.local/share/virtualenvs/mujoco-py-w-7Ahox1/include/python3.6m -c /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/cymj.c -o /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.2_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/cymj.o -fopenmp -w
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py -I/home/brianbeckman/.mujoco/mujoco200/include -I/home/brianbeckman/.local/share/virtualenvs/mujoco-py-w-7Ahox1/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -I/home/brianbeckman/.local/share/virtualenvs/mujoco-py-w-7Ahox1/include/python3.6m -c /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/gl/osmesashim.c -o /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.2_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/gl/osmesashim.o -fopenmp -w
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.2_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/cymj.o /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.2_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/gl/osmesashim.o -L/home/brianbeckman/.mujoco/mujoco200/bin -Wl,--enable-new-dtags,-R/home/brianbeckman/.mujoco/mujoco200/bin -lmujoco200 -lglewosmesa -lOSMesa -lGL -o /home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.2_36_linuxcpuextensionbuilder/lib.linux-x86_64-3.6/mujoco_py/cymj.cpython-36m-x86_64-linux-gnu.so -fopenmp
Traceback (most recent call last):
File "<input>", line 4, in <module>
File "/home/brianbeckman/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/home/brianbeckman/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/brianbeckman/Documents/GitHub/mujoco-py/examples/markers_demo.py", line 8, in <module>
from mujoco_py import load_model_from_xml, MjSim, MjViewer
File "/home/brianbeckman/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/__init__.py", line 3, in <module>
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "/home/brianbeckman/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/builder.py", line 503, in <module>
cymj = load_cython_ext(mujoco_path)
File "/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/builder.py", line 106, in load_cython_ext
mod = load_dynamic_ext('cymj', cext_so_path)
File "/home/brianbeckman/Documents/GitHub/mujoco-py/mujoco_py/builder.py", line 124, in load_dynamic_ext
return loader.load_module()
ImportError: libglewosmesa.so: cannot open shared object file: No such file or directory

1
Avatar
Permanently deleted user

404 :(

1
Avatar
Permanently deleted user

Oh, I referenced an issue that I created. Didn't realize this is not public. I'll try to briefly summarise: pipenv needs the locale set to UTF-8 (see pipenv FAQ). For me, a previous versions of PyCharm seemed to set this automatically. And now the current version does not pick up this variable from the shell, because I launched PyCharm from MacOs spotlight instead as from a shell. When I launch from shell with the locale env vars set properly, pipenv works inside PyCharm. But I don't know if this is what is causing your issue.

1

This thread is marked as "answered"... but clearly it's NOT answered!   The link given in a previous comment is broken....

I, too, experienced a "pipenv project working on command line but not in pycharm" - which I just reported in this other thread: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360005143979-Apparent-BUG-in-Linux-PyCharm-s-built-in-support-of-pipenv

1
Avatar
Permanently deleted user

The problem did disappear for me though. On MacOS at least.

0

请先登录再写评论。