Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyGPs code problem
#1
(**English is not my native language; please excuse typing errors.)
I just installed a site package pyGPs(via 'pip install pyGPs', you can also download from https://github.com/marionmari/pyGPs), and after I try to run to ensure that it was correctly installed, Some problems occured: 'pyGPs\__init__' and 'pyGPs\Core\__init__' these two files said that the errors are from each other, and file 'pyGPs\Core\gp' can not run either. I try to find and search through Google but I cant found what is wrong with them:
pyGPs\__init__:
from __future__ import absolute_import
import Optimization
import Validation
import GraphExtensions
from Core import *
from Core.gp import *

__all__ = ['Optimization', 'Validation', 'GraphExtensions', 'Core']
Error:
Traceback (most recent call last): File "C:\Users\elatm\anaconda3\Lib\site-packages\pyGPs\__init__.py", line 5, in <module> from Core import * File "C:\Users\elatm\anaconda3\Lib\site-packages\pyGPs\Core\__init__.py", line 6, in <module> import gp ModuleNotFoundError: No module named 'gp'
pyGPs\Core\__init__:
from __future__ import absolute_import
import inf
import cov
import mean
import lik
import gp
import opt



__all__ = ['inf', 'cov', 'mean', 'lik','gp','opt']
Error:
Traceback (most recent call last): File "C:\Users\elatm\anaconda3\Lib\site-packages\pyGPs\Core\__init__.py", line 6, in <module> import gp File "C:\Users\elatm\anaconda3\Lib\site-packages\pyGPs\Core\gp.py", line 51, in <module> import inf, mean, lik, cov, opt File "C:\Users\elatm\anaconda3\Lib\site-packages\pyGPs\Core\opt.py", line 29, in <module> from pyGPs.Optimization import minimize, scg File "C:\Users\elatm\anaconda3\lib\site-packages\pyGPs\__init__.py", line 5, in <module> from Core import * ModuleNotFoundError: No module named 'Core'
pyGPs\Core\gp:
...
import itertools
import numpy as np
import matplotlib.pyplot as plt
import inf, mean, lik, cov, opt
from tools import unique, jitchol, solve_chol
from copy import deepcopy
import pyGPs
from pyGPs.Core.cov import FITCOfKernel
...
Error:
Traceback (most recent call last): File "C:\Users\elatm\anaconda3\Lib\site-packages\pyGPs\Core\gp.py", line 51, in <module> import inf, mean, lik, cov, opt File "C:\Users\elatm\anaconda3\Lib\site-packages\pyGPs\Core\opt.py", line 29, in <module> from pyGPs.Optimization import minimize, scg File "C:\Users\elatm\anaconda3\lib\site-packages\pyGPs\__init__.py", line 5, in <module> from Core import * ModuleNotFoundError: No module named 'Core'
The first two errors said that no module named 'gp', but there is a module name gp; and the third error said that no module named 'Core', still there is a module name Core. So I wonder what are they talking about, should I reinstall them or there is something I miss in my site package? My objective is to run the file without error
(my python version is 3.8.3)
Reply
#2
It is unclear what exactly you are running after doing the install. You should not be trying to run those files directly, but should be importing pyGPs into your script.

As an example, this file should run without error.

import pyGPs
print("import successful")
Output:
$ python test.py import successful
If that works okay, you should be able to call the pyGPs functions from within your script.
Reply
#3
I see some differences between the behavior of the package and the documentation. I wonder if the code has undergone some updates and the documentation hasn't kept up?

One of the examples suggests that this should work:

import pyGPs
import numpy as np
model = pyGPs.GPR()      # specify model (GP regression)
But it doesn't. I was able to get it to work (and the demo to draw data) by making the following modifications:

import pyGPs
import pyGPs.Core.gp
import numpy as np
model = pyGPs.Core.gp.GPR()      # specify model (GP regression)
Reply
#4
(Oct-16-2020, 07:38 PM)bowlofred Wrote: It is unclear what exactly you are running after doing the install. You should not be trying to run those files directly, but should be importing pyGPs into your script.

As an example, this file should run without error.

import pyGPs
print("import successful")
Output:
$ python test.py import successful
If that works okay, you should be able to call the pyGPs functions from within your script.

I try to do what you said, and I found some strange things:
import pyGPs
print("import successful")
and it shows
Error:
Traceback (most recent call last): File "C:\Users\elatm\.spyder-py3\temp.py", line 9, in <module> import pyGPs File "C:\Users\elatm\anaconda3\lib\site-packages\pyGPs\__init__.py", line 2, in <module> import Optimization ModuleNotFoundError: No module named 'Optimization'
So I check the place where it is wrong:
from __future__ import absolute_import
import Optimization
import Validation
import GraphExtensions
from Core import *
from Core.gp import *

__all__ = ['Optimization', 'Validation', 'GraphExtensions', 'Core']
and the error is
Error:
Traceback (most recent call last): File "C:\Users\elatm\anaconda3\lib\site-packages\pyGPs\__init__.py", line 2, in <module> import Optimization File "C:\Users\elatm\anaconda3\lib\site-packages\pyGPs\Optimization\__init__.py", line 2, in <module> import scg ModuleNotFoundError: No module named 'scg'
I go check the error place
from __future__ import absolute_import
import scg
import minimize
import conf
but it turns out that the script above is correct(no error)
When I go back to the first script, same error occur again, and the error occur in the second script changes
the second script:
from __future__ import absolute_import
import Optimization
import Validation
import GraphExtensions
from Core import *
from Core.gp import *

__all__ = ['Optimization', 'Validation', 'GraphExtensions', 'Core']
the error changes to
Error:
Traceback (most recent call last): File "C:\Users\elatm\anaconda3\lib\site-packages\pyGPs\__init__.py", line 3, in <module> import Validation File "C:\Users\elatm\anaconda3\lib\site-packages\pyGPs\Validation\__init__.py", line 2, in <module> import valid ModuleNotFoundError: No module named 'valid'
Then I run the script 'valid':
from __future__ import absolute_import
import valid
the script is correct, and all of these become an error cycle: go back to first script, encounter error in first script, check second script(another error occur), run file(the file runs without error),go back to first script again...
It will finally output successfully
Output:
import successful
but it requires lots of 'fixing', and can't run with the only script open:
import pyGPs
print("import successful")
I can't import pyGPs without having to open all the other files, is this a normal situation? If not, does the version matters or the installation isn't correct?
Reply
#5
(Oct-16-2020, 07:38 PM)bowlofred Wrote: It is unclear what exactly you are running after doing the install. You should not be trying to run those files directly, but should be importing pyGPs into your script.

As an example, this file should run without error.

import pyGPs
print("import successful")
Output:
$ python test.py import successful
If that works okay, you should be able to call the pyGPs functions from within your script.
I just reinstall pyGPs agian and test it and I can import pyGPs right now. Then I remember I changed some script inside pyGPs in order to make them run independently(which means nothing), that may be the reason that the errors occur. Bowlofred I thank for your help.
Reply
#6
(Oct-16-2020, 08:14 PM)bowlofred Wrote: I see some differences between the behavior of the package and the documentation. I wonder if the code has undergone some updates and the documentation hasn't kept up?

One of the examples suggests that this should work:

import pyGPs
import numpy as np
model = pyGPs.GPR()      # specify model (GP regression)
But it doesn't. I was able to get it to work (and the demo to draw data) by making the following modifications:

import pyGPs
import pyGPs.Core.gp
import numpy as np
model = pyGPs.Core.gp.GPR()      # specify model (GP regression)
I have the same thought, the documentation might not be updated for a long time so that some of the demo scripts can run, but some can't. They just have to be changed manually.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020