error "no module named jplephem.pck" when trying to use skyfield - python

I was trying to work with skyfield and I got the error that:
"ModuleNotFoundError: No module named 'jplephem.pck'"
I get the error in the first line itself
it goes like this:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-3a2b53f77cba> in <module>
----> 1 from skyfield.api import load
2
3 planets = load('de421.bsp')
4 earth, mars = planets['earth'], planets['mars']
5
~\Anaconda3\lib\site-packages\skyfield\api.py in <module>
12 from .errors import DeprecationError
13 from .iokit import Loader, load_file
---> 14 from .planetarylib import PlanetaryConstants
15 from .positionlib import position_from_radec
16 from .starlib import Star
~\Anaconda3\lib\site-packages\skyfield\planetarylib.py in <module>
3 import re
4 from numpy import array, cos, einsum, nan, rollaxis, sin
----> 5 from jplephem.pck import DAF, PCK
6 from .constants import ASEC2RAD, AU_KM, DAY_S, tau
7 from .functions import rot_x, rot_y, rot_z
ModuleNotFoundError: No module named 'jplephem.pck'
I tried to look it up on the net and it said that it is a dependency and I do not know what to do to debug this
from skyfield.api import load
planets = load('de421.bsp')
earth, mars = planets['earth'], planets['mars']
ts = load.timescale()
t = ts.now()
position = earth.at(t).observe(mars)
ra, dec, distance = position.radec()
print(ra)
print(dec)
print(distance)
Any form of help will be appreciated

Did you install Skyfield with pip install skyfield, or through another mechanism? Current versions of Skyfield have a setup.py that insists on a recent version of jplephem because only versions more recent than 2.11 will have the pck module that Skyfield needs. The pip install tool should have detected this, but if it did not, doing pip install -U jplephem to force an update of jplephem should get you going again!
Workaround
If you are using conda, you will be installing an old version. Try:
conda uninstall jplephem
pip install -U jplephem
Real solution
The long-term solution is for the conda folks to get their packaging of this library working again. The list of pull requests on their "feedstock" for the library looks like it has encountered repeated failures to build and distribute an up-to-date package:
But the most recent PR is hand-written and has asked for moderator attention, so hopefully things will get fixed.

Related

DDSP colab demo import error / ModuleNotFoundError: No module named 'crepe'

I tried to use the demo of the DDSP model developed by Google Research in colab, but there was an error during the import stage, so I couldn't import it.
This problem didn't happen until recently, but suddenly an error is occurring.
`
##title #Install and Import
##markdown Install ddsp, define some helper functions, and download the model. This transfers a lot of data and _should take a minute or two_.
print('Installing from pip package...')
!pip install -qU ddsp==1.6.5 "hmmlearn<=0.2.7"
# Ignore a bunch of deprecation warnings
import warnings
warnings.filterwarnings("ignore")
import copy
import os
import time
import crepe
import ddsp
import ddsp.training
from ddsp.colab.colab_utils import (
auto_tune, get_tuning_factor, download,
play, record, specplot, upload,
DEFAULT_SAMPLE_RATE)
from ddsp.training.postprocessing import (
detect_notes, fit_quantile_transform
)
import gin
from google.colab import files
import librosa
import matplotlib.pyplot as plt
import numpy as np
import pickle
import tensorflow.compat.v2 as tf
import tensorflow_datasets as tfds
# Helper Functions
sample_rate = DEFAULT_SAMPLE_RATE # 16000
print('Done!')
`
It seems to be a problem with the version, so I tried to upgrade the pip and install the pip before importing the module according to the guide, but it still hasn't been solved.
Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: etils 0.9.0 does not provide the extra 'epath-no-tf'
A similar warning will continue to be displayed below...
`
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-fb97381ec3fd> in <module>
13 import time
14
---> 15 import crepe
16 import ddsp
17 import ddsp.training
ModuleNotFoundError: No module named 'crepe'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
`
This error is output if I stop importing.

KeyError: 'vendor_id' when installing packages

I am attempting to carry out lens correction and I've fallen at the first hurdle. After running the following code, I receive this error...
#Install required packages
!pip install opencv-python
import cv2
import numpy as np
import pathlib
!pip install chessboard
from chessboard import calibrate_chessboard
from utils import load_coefficients, save_coefficients
KeyError Traceback (most recent call last)
<ipython-input-19-0a40b3424bef> in <module>()
6 import pathlib
7 get_ipython().system('pip install chessboard')
----> 8 from chessboard import calibrate_chessboard
9 from utils import load_coefficients, save_coefficients
2 frames
/usr/local/lib/python3.7/dist-packages/chessboard/benchmark.py in Benchmark()
105 ('machine', platform.machine()),
106 # CPU.
--> 107 ('cpu_vendor', cpu_info['vendor_id']),
108 ('cpu_model', cpu_info['brand']),
109 ('cpu_freq_actual', cpu_info['hz_actual'][0]),
KeyError: 'vendor_id'
Can anyone help with this please?
It looks like that you are using outdated package chessboard, not updated since 2017, repo now archived.
It rely on another package py-cpuinfo. There is this issue. The key vendor_id is now replaced with vendor_id_raw. Note that setup.py for chessboard does not specify version for py-cpuinfo, so I guess you use the latest one.
One way to solve the problem is to use specific older version of py-cpuinfo before that change. The latest version of py-cpuinfo with vendor_id is 5.0.0. The latest version before latest chessboard release date is 3.3.0
Another option is to try and replace key vendor_id with vendor_id_raw everywhere inside chessbeoard package.
My preference would be with the second option as chessboard is no longer developed. In any case be aware there might be other issues or unwanted behaviour.

Can´t import qiskit, attribute error in numpy: " 'numpy.random' has no attribute 'default_rng'"

I´m using Python 3 and I´m working in jupyter, when I try to import qiskit the following error is showed:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-578b7f7e9727> in <module>
----> 1 import qiskit
~\AppData\Roaming\Python\Python36\site-packages\qiskit\quantum_info\synthesis\two_qubit_decompose.py in __init__(self, unitary_matrix)
169 # D, P = la.eig(M2) # this can fail for certain kinds of degeneracy
170 for i in range(100): # FIXME: this randomized algorithm is horrendous
--> 171 state = np.random.default_rng(i)
172 M2real = state.normal()*M2.real + state.normal()*M2.imag
173 _, P = la.eigh(M2real)
AttributeError: module 'numpy.random' has no attribute 'default_rng'
I got almost the same error as:
AttributeError: module 'numpy.random' has no attribute 'default_rng'
with the numpy version of '1.16.2'
numpy.__version__
'1.16.2'
As a solution, either you need to put these lines at the top of your file:
import numpy
numpy.random.bit_generator = numpy.random._bit_generator
Or the your current numpy version probably is <= 1.17. Hence, you need to update the NumPy version. For instance, I have updated it on Anaconda environment as:
conda update numpy
And the current version is:
numpy.__version__
'1.19.2'
Updates take time because of lots of dependencies of NumPy. Hopefully, the issue is resolved on my side!
You need NumPy 1.17 or later to have the new RNG functions that Qiskit needs
if you're using jupyter in anaconda - uninstalling, reinstalling and restarting the kernel worked for me similar here: AttributeError: module 'numpy' has no attribute '__version__'
!pip uninstall -y numpy
!pip install numpy
RESTART KERNEL

R_HOME Error with rpy2

I know there are quite a few posts on getting up and running with rpy2 on windows 7 32 bit. I have referenced a good number of them and attempted their solutions, including the use of PypeR.
I dont explicitly have a R_HOME variable set in my path, but per this question, I confirmed that R is in my PATH (I can type R at the command line and get R to run) and even copied all of the files from the i386 folder to the parent bin folder.
My issue is pasted below. Any thoughts?
In [5]: from rpy2 import robjects
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-1f019d00d232> in <module>()
----> 1 from rpy2 import robjects
C:\Anaconda\lib\site-packages\rpy2\robjects\__init__.py in <module>()
16 import rpy2.rlike.container as rlc
17
---> 18 from rpy2.robjects.robject import RObjectMixin, RObject
19 from rpy2.robjects.vectors import *
20 from rpy2.robjects.functions import Function, SignatureTranslatedFunction
C:\Anaconda\lib\site-packages\rpy2\robjects\robject.py in <module>()
3 import rpy2.rinterface
4
----> 5 rpy2.rinterface.initr()
6
7 import conversion
RuntimeError: R_HOME not defined.
I confirm this issue is related to R_HOME variable not defined.
In my opinion, all of these issues are caused because the developers of rpy2 package haven't documented properly the requirements of their software:
Install R
Create R_HOME system variable
Add R_HOME\bin to the PATH, in order to execute R from python
Add R_HOME\bin\x64 to the PATH, in order to load R.dll
Install package tzlocal
With help from the comment above, I got moving in the proper direction. I created the R_HOME as a SYSTEM variable. That didn't work right away, as I was getting an R_USER not defined error.
To get everything the import above to work without error, I simply re-installed the rpy2 exectuable from here after defining the R_HOME. No errors.
In summary, key was o have R_HOME set PRIOR TO installing rpy2.

linking to audiolab in python2.6 on osx

I've been unable to get scikits.audiolab working on OS X. I've tried easy_install and building from source, but both give me the same error:
----> 1 import scikits.audiolab
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scikits.audiolab-0.11.0-py2.6-macosx-10.3-fat.egg/scikits/audiolab/__init__.py in <module>()
23 __version__ = _version
24
---> 25 from pysndfile import formatinfo, sndfile
26 from pysndfile import supported_format, supported_endianness, \
27 supported_encoding, PyaudioException, \
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scikits.audiolab-0.11.0-py2.6-macosx-10.3-fat.egg/scikits/audiolab/pysndfile/__init__.py in <module>()
----> 1 from _sndfile import Sndfile, Format, available_file_formats, \
2 available_encodings, sndfile_version
3 from compat import formatinfo, sndfile, PyaudioException, PyaudioIOError
4 from compat import supported_format, supported_endianness, supported_encoding
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scikits.audiolab-0.11.0-py2.6-macosx-10.3-fat.egg/scikits/audiolab/pysndfile/_sndfile.so, 2): Symbol not found: _sf_close
Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scikits.audiolab-0.11.0-py2.6-macosx-10.3-fat.egg/scikits/audiolab/pysndfile/_sndfile.so
Expected in: dynamic lookup
_sndfile.so is created in the location it describes, so it's some weird problem linking to it as, far as I can see. Got me stumped. I'm on the point of abandoning audiolab.
I can't use the built in scipy method for loading wavs as it doesn't work with 24-bit WAVs.
Audiolab requires libsndfile. I had installed that via MacPorts, but it had built as x86_64 only by default.
Deleting all installs and reinstalling libsndfile with the +universal flag built it as i386 and x86_64.
Now I could install audiolab from source and it linked properly. :)

Categories