can someone help me?
This is my code:
import traffic
from traffic.core import Traffic
import pickle
import pandas as pd
import numpy as np
import os
from numpy import sqrt, argmax
from matplotlib import pyplot
import matplotlib.pyplot as plt
from traffic.data import SO6
import math
from geographiclib.geodesic import Geodesic
from traffic.data import nm_airspaces
#BBDD INITIAL
geod = Geodesic.WGS84
bbdd_initial=SO6.from_file('initial.so6')
bdx_so6 = bbdd_initial.inside_bbox(nm_airspaces['LSAZM456'])*
And, when I run it, it gives me an error and I don't know how to fix it:
*RuntimeError Traceback (most recent call last)
<ipython-input-66-f276e3cdb85c> in <module>
bbdd_inicial=SO6.from_file('initial.so6')
bdx_so6 = bbdd_inicial.inside_bbox(nm_airspaces['LSAZM456'])
~\anaconda3\envs\AISAenv\lib\site-packages\traffic\data\eurocontrol\ddr\airspaces.py in
__getitem__(self, name)
if not self.initialized:
self.init_cache()
list_names = self.airspaces.get(name, None)
~\anaconda3\envs\AISAenv\lib\site-packages\traffic\data\eurocontrol\ddr\airspaces.py in
init_cache(self)
if self.nm_path is None:
raise RuntimeError(msg)
are_file = next(self.nm_path.glob("Sectors_*.are"), None)
RuntimeError: Edit file C:\Users\Usuario\AppData\Local\traffic\traffic\traffic.conf with NM
directory
I am trying to obtain the trajectory which is within a sector. If that doesn´t have solution, is there any way to get that?
Related
I am trying to import matplotlib in .ipynb file but its not working, none of my files have the same name as _docstring yet I get this error and if I try something in .py file, it works fine.
import numpy as np
import matplotlib.pyplot as plt
import cv2 as cv
I'm running this in a .ipynb file in VS Code
Output :
ImportError Traceback (most recent call last)
Cell In[3], line 2
1 import numpy as np
----> 2 import matplotlib.pyplot as plt
3 import cv2 as cv
File c:\Users\P****\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\__init__.py:113
109 from packaging.version import parse as parse_version
111 # cbook must import matplotlib only within function
112 # definitions, so it is safe to import from it here.
--> 113 from . import _api, _version, cbook, _docstring, rcsetup
114 from matplotlib.cbook import sanitize_sequence
115 from matplotlib._api import MatplotlibDeprecationWarning
ImportError: cannot import name '_docstring' from partially initialized module 'matplotlib' (most likely due to a circular import) (c:\Users\P****\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\__init__.py)
But if I try to import matplotlib in .py file like
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1,10,0.1)
y = x**2
plt.plot(x,y)
plt.show()
It runs fine, no issues.
Try deleting matplotlib folder and reinstalling it.
Full path: AppData\Roaming\Python\Python39\site-packages\matplotlib
It worked for me.
I am trying to run a .py script on my Manjaro box and I keep getting the following error:
[keithm#home2 python]$ python3 gspppff.py
['/home/keithm/bin/python', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/keithm/.local/lib/python3.8/site-packages', '/usr/lib/python3.8/site-packages']
Traceback (most recent call last):
File "gspppff.py", line 7, in <module>
import matplotlib.pylot as plt
ModuleNotFoundError: No module named 'matplotlib.pylot'
Here's the script:
#!/usr/bin/python
import datetime as dt
import sys
print(sys.path)
import matplotlib.pylot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
# graph style
style.use('ggplot')
start = dt.datetime(2020, 1, 1)
end = dt.datetime.now()
# dataframe
df = web.DataReader("TSLA", 'morningstar', start, end)
print(df.head())
I included print(sys.path) to see where python was looking for the mods and I made sure matlablib was installed in both locally: /home/keithm/.local/lib/python3.8/site-packages and in /usr/lib/python3.8/site-packages, but still no change.
The package name is "pyplot", not "pylot". Here is the corrected code:
import matplotlib.pyplot as plt
It's spelled "pyplot", not "pylot".
import matplotlib.pyplot as plt
try "pyplot" you have incorrect spelling
I am using macOS Mojave and trying to run the following:
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import optim
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from pyvirtualdisplay import Display
from IPython import display as ipythondisplay
from IPython.display import clear_output
from pathlib import Path
import random, os.path, math, glob, csv, base64, itertools, sys
import gym
from gym.wrappers import Monitor
from pprint import pprint
# The following code is will be used to visualize the environments.
def show_video(directory):
html = []
for mp4 in Path(directory).glob("*.mp4"):
video_b64 = base64.b64encode(mp4.read_bytes())
html.append('''<video alt="{}" autoplay
loop controls style="height: 400px;">
<source src="data:video/mp4;base64,{}" type="video/mp4" />
</video>'''.format(mp4, video_b64.decode('ascii')))
ipythondisplay.display(ipythondisplay.HTML(data="<br>".join(html)))
display = Display(visible=0, size=(1400, 900))
display.start();
But when I try to run the above, I get the following error:
---------------------------------------------------------------------------
XStartTimeoutError Traceback (most recent call last)
<ipython-input-1-73a977c6bd7e> in <module>
31
32 display = Display(visible=0, size=(1400, 900))
---> 33 display.start();
34
35 def make_seed(seed):
/usr/local/lib/python3.7/site-packages/pyvirtualdisplay/abstractdisplay.py in start(self)
166 if not ok:
167 msg = 'Failed to start X on display "%s" (xdpyinfo check failed).'
--> 168 raise XStartTimeoutError(msg % d)
169 return self
170
XStartTimeoutError: Failed to start X on display ":1001" (xdpyinfo check failed).
The only close thing I get is Why am I getting this message from xauth: “timeout in locking authority file /home//.Xauthority”?
which is not really what I am facing here. How can I fix this issue?
I had the same issue. Then I installed and started XQuartz this problem got resolved.
In my master file I have:
import matplotlib.pyplot as plt
import seaborn
import numpy as np
import time
import sys
sys.path.append("C:/.../python check/createsplit")
import createsplit
data='MJexample'
X,Y,N,Ntr=create_training_data(data)
where I am calling create_training_data function from createsplit.py file which is:
import numpy as np
import scipy.io
def create_training_data(data_type):
"""
creates training data
"""
if data_type=='MJexample':
N=300
Ntr = 150
X=np.linspace(0,1,N)
X = np.array([X,X*X,np.linspace(5,10,N),np.sin(X),np.cos(X),np.sin(X)*np.cos(X)]).T
fac=40
Y=np.array([np.sin(fac*x)*np.cos(fac*x**2) for x in X[:,0]])[:,None]
_X=X
_Y=Y
return _X,_Y,N,Ntr
However running my original file results in error: NameError: global name 'np' is not defined for some reason I do not understand. I assume I am importing the functions in a wrong way but I don't really understand what would be wrong.
I think this issue raises just because of a wrong call of the function. Try
X, Y, N, Ntr = createsplit.create_training_data(data)
instead, and it should work.
I'm attempting to import a function defined in another file into the one I am working in.
The function I'm trying to import is in a file called ParallelEqns.py and looks like:
import sys
import numpy as np
import scipy as sp
import sympy as sym
import matplotlib.pyplot as plt
import os
def ParDeriv(x,p):
derivative = []
for k in range(nS):
test = x[(k-1)%nS]*(x[(k+1)%nS] - x[(k-2)%nS]) - x[(k)%nS] + p
if k == 0:
derivative = test
else:
derivative = np.vstack([derivative, test])
return derivative
The file I'm working in looks like:
import sys
import numpy as np
import scipy as sp
import sympy as sym
import matplotlib.pyplot as plt
import os
from ParallelEqns import ParDeriv
That gives me an error of "cannot import name 'ParDeriv'"
If I change the file to:
import sys
import numpy as np
import scipy as sp
import sympy as sym
import matplotlib.pyplot as plt
import os
import ParallelEqns
ParDeriv = ParallelEqns.ParDeriv
I get an error that says "module 'ParallelEqns' has no attribute 'ParDeriv'"
I've checked that both files are in the same directory. I'm not sure what I'm doing wrong here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Edit: I've answered my own question by closing everything down and restarting python. It looks like I needed to restart python after creating the ParallelEqns.py file for it to correctly import
It turns out I just needed to restart python as I had created the file that I was trying to import after starting up python. Once I did that it worked out