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

Import Error - Module cannot be found #516

Open
calvinp0 opened this issue Nov 22, 2022 · 5 comments
Open

Import Error - Module cannot be found #516

calvinp0 opened this issue Nov 22, 2022 · 5 comments

Comments

@calvinp0
Copy link

calvinp0 commented Nov 22, 2022

Hi,

I am attempting to use PyCharm as my IDE debugger. In my code I call on PyJulia to import a package that our group created. However, after we attempt to run this code

import julia
import diffeqpy

julia.install()
diffeqpy.install()
from julia.api import Julia

jl = Julia(compiled_modules=False)
from julia import Pkg

Pkg.add("ReactionMechanismSimulator")
from julia import ReactionMechanismSimulator

We receive an error during the last line, the import line, saying that there was an Import Error and that ReactionMechanismSimulator could not be found. Any advice on how to deal with this issue?

@mkitti
Copy link
Member

mkitti commented Nov 22, 2022

What is the output of Pkg.status()? If you start Julia directly, do you see the package in your environment? How did you install julia, pyjulia, and python?

@calvinp0
Copy link
Author

Thanks for the response!

Here is the Pkg.status("ReactionMechanismSimulator"):

Status `~/mambaforge/envs/rmg_env/share/julia/site/environments/v1.8/Project.toml`
  [c2d78dd2] ReactionMechanismSimulator v0.4.0 `https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl.git#main`

In regards to the installation of all three, Python is 3.7.12 and it was installed using an mamba, creating the env from environment.yml file. PyJulia was also installed that way.

Then for julia, the commands we ran:

python -c "import julia; julia.install(); import diffeqpy; diffeqpy.install()"

julia -e 'using Pkg; Pkg.add(PackageSpec(name="ReactionMechanismSimulator",rev="main")); using ReactionMechanismSimulator;'

@calvinp0
Copy link
Author

calvinp0 commented Nov 22, 2022

After some fiddling around... I was able to import ReactionMechanismSimulator but now when I attempt to call a function from it, it cannot find it.

input

import julia.Pkg as PKG
PKG.add("ReactionMechanismSimulator")
from julia import ReactionMechanismSimulator
from julia.ReactionMechanismSimulator import makefluxdiagrams

output

Traceback (most recent call last):
  File "/home/calvin/mambaforge/envs/rmg_env/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3552, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-18-8708db1d8430>", line 1, in <module>
    from julia.ReactionMechanismSimulator import makefluxdiagrams
  File "/snap/pycharm-professional/311/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/home/calvin/mambaforge/envs/rmg_env/lib/python3.7/site-packages/julia/core.py", line 260, in load_module
    raise ImportError("{} not found".format(juliapath))
ImportError: ReactionMechanismSimulator.makefluxdiagrams not found

The current package status:

PKG.status("ReactionMechanismSimulator")
      Status `~/.julia/environments/v1.6/Project.toml`
  [c2d78dd2] ReactionMechanismSimulator v0.4.0 `https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl.git#main`

In case you are wondering, I imported Pkg as import julia.Pkg as PKG because whenever I attempt to do from julia import Pkg, I receive a segmentation fault on PyCharm. No idea why.

@mkitti
Copy link
Member

mkitti commented Nov 22, 2022

Can you call ReactionMechanismSimulator.makefluxdiagrams()?

@calvinp0
Copy link
Author

Sorry for the late response. I attempted your suggestion but get the same issue:

ReactionMechanismSimulator.makefluxdiagrams()
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/calvin/mambaforge/envs/t3_env/lib/python3.7/site-packages/julia/core.py", line 175, in __getattr__
    return self.__try_getattr(name)
  File "/home/calvin/mambaforge/envs/t3_env/lib/python3.7/site-packages/julia/core.py", line 198, in __try_getattr
    raise AttributeError(name)
AttributeError: makefluxdiagrams

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

No branches or pull requests

2 participants