I am posting the solution to the problem in case anyone else has this 
issue. It is important to set the PYTHON variable in Julia to the binary 
used in the python virtual environment. For example, once the virtual 
environment is activated,

% (venv) which python
>  /path/to/venv/binary

then in the Julia console:

% ENV["PYTHON"] = "/path/to/venv/binary"

my error in particular was including "~" in the path out of habit, which 
expands in bash, but obviously not in Julia. "import _locale" worked in the 
Python terminal because it was launched with the correct binary. 


On Monday, October 24, 2016 at 5:38:04 PM UTC-4, Corbin Foucart wrote:
>
> I would like to use pyjulia, but I am having some issue setting it up in 
> my python virtual environment. I have followed the instructions here: 
> https://github.com/JuliaPy/pyjulia
>
> I am running the following script:
>
>  import julia
>  j = 
> julia.Julia(jl_runtime_path='/share/apps/julia/julia-3c9d75391c/bin/julia', 
> debug=True) 
>
> The output:
>
> % python juliaSetup.py 
> >JULIA_HOME = /share/apps/julia/julia-3c9d75391c/bin,  libjulia_path = 
> /share/apps/julia/julia-3c9d75391c/bin/../lib/libjulia.so.0.5
> >calling jl_init(/share/apps/julia/julia-3c9d75391c/bin)
> >seems to work...
> >exception occured? None
> >WARNING: redefining constant JULIA_HOME
> >exception occured? None
> >exception occured? None
> >exception occured? None
> >Traceback (most recent call last):
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 552, in <module>
>     main()
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 530, in main
>     known_paths = addusersitepackages(known_paths)
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 266, in addusersitepackages
>     user_site = getusersitepackages()
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 241, in getusersitepackages
>     user_base = getuserbase() # this will also set USER_BASE
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 231, in getuserbase
>     USER_BASE = get_config_var('userbase')
>  > File 
> "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/sysconfig.py", 
> line 520, in get_config_var
>     return get_config_vars().get(name)
>  > File 
> "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/sysconfig.py", 
> line 453, in get_config_vars
>     import re
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/re.py", 
> line 108, in <module>
>     import _locale
> > SystemError: dynamic module not initialized properly
>
> Pursuant to the error stack, I launched a python terminal and tried 
> "import _locale" with no issue. Does anyone know what is going on?
>
>

Reply via email to