I am trying to run a python script on my mac but
"Unable to revert mtime: /Library/Fonts"
keeps popping up when i run the program. i have the latest version of python installed as well as matplotlib. i am very new to python so i do not know what the issue is but here is the snippet of the code:
from plotly import graph_objs as go
import matplotlib.pyplot as plt
import numpy as np
import json
import datetime
with open('ELIX.json') as json_file:
data = json.load(json_file)
you need to have libmagic
brew install libmagic
In my situation, I had to restore the fonts that came with my system. To do so:
Open up the Font Book app
Go to File
Click Restore Standard Fonts
Video: https://www.loom.com/share/379ad4f9539d4730af75039623027888
Related
so my objective is to test a piechart from a code i found for visualizing stocks, kind of a portfolio. The problem is, that i always get an error. I tried using the jupyter notebook, which isnt as useful as I thougt. I am working with User Inputs. In the following are the libraries I used and the full code. Thanks in advance.
import datetime
import yfinance as yf
import plotly.graph_objects as go
https://github.com/NoamYakarOfficial/StockPortfolioVisualizer
it's working Vs code
can you check the python version or python extension install vs code,
after opening the terminal install packages
Can you run this way:
pip install yfinance
pip install plotly
fig.write_image("images/fig1.png",format='png',engine='kaleido')
This makes my VSCode go bananas, the terminal hangs and the program stops then and there. Everything works fine if I remove just that line.
I want to save the plots as pngs, but it is not working. I have kaleido installed.
Try this version of kaleido.
pip install kaleido==0.1.0post1
It works for me
Complete MWE. png gets created as expected.
import plotly.graph_objects as go
import numpy as np
from pathlib import Path
f = Path.cwd().joinpath("images")
if not f.is_dir(): f.mkdir()
f = f.joinpath("fig1.png")
fig = go.Figure(go.Scatter(x=np.linspace(1,10,100), y=np.sin(np.linspace(-np.pi,np.pi, 100))))
fig.write_image(f,format='png',engine='kaleido')
versions
import plotly
import kaleido
print(plotly.__version__, kaleido.__version__)
5.5.0 0.2.1
Please follow what Gillian Grayson suggested. I am using Jupyter Notebook, Plotly version 5.13.0 and Kaleido 0.1.0.post1 and Python 3.8
Also add this to make saving figure faster
import plotly
plotly.io.kaleido.scope.mathjax= None
I'm trying to run reticulate and import python modules within r studio (specifically R-markdown). The R code chunk seems to do what is expected (i.e. install the python modules) and not seem to produce any errors, but the python code chunk does not seem to do what is expected (i.e. import the installed packages). It does not produce any output (or errors) which is somewhat strange.
I've tried a fresh install of reticulate, using the devtools version of reticulate a fresh install of R Studio and using the full conda path rather than the name, but neither seem to be working. I'm at a loss to figure out what is going wrong. I've also searched stackoverflow for various answers already and have tried various suggestions, but nothing seems to be working). Additionally, I have miniconda installed and python installed as well (and python packages and scripts run perfectly fine). If anyone was able to help, that would be fantastic.
(Apologies for formatting, the last backticks indicating the end of the code chunks aren't showing up properly)
## R code chunk
```
```{r}
library("reticulate")
#devtools::install_github("rstudio/reticulate")
conda_create("my_project_env")
py_install(packages = c("numpy","pandas","scikit-learn","matplotlib","seaborn","statsmodels"))
py_install(packages = c("IPython"))
# Either of these seem to "work" for installation
#conda_install(packages = c("numpy","pandas","scikit-learn","matplotlib","seaborn","statsmodels"))
#conda_install(packages = c("IPython"))
conda_list()
use_condaenv("my_project_env")
```
The python code chunk below seems to "run" but does not produce any output or errors (such as the python module could not be found) and I am unable to use the modules.
## Python code chunk
```
```{python}
# Main packages
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
```
It seems like the solution was to run the imports in an r studio code chunk in the following manner :
library("reticulate")
conda_create("my_project_env")
py_install(packages = c("numpy","pandas","scikit-learn","matplotlib","seaborn","statsmodels"))
conda_list()
use_condaenv("full_path_to_python_for my_project_env")
py_run_string('import numpy as np')
py_run_string('import pandas as pd')
py_run_string('import matplotlib.pyplot as plt')
py_run_string('import seaborn as sns')
From there, I was able to run the python functions in the python code chunks without issue.
I am currently in PyCharm and I have the following line of code:
import cv2
Nonetheless, it gives me the error No module named cv2
I went to Preferences > Project Interpreter > + then found and downloaded cv2 just fine. In the Project Interpreter it lists cv2 as installed. I am not sure why it still shows that the module doesn't exist. Is there some way to download cv2 via command line. I am on OS X 10.10.
Here is the code I have so far (all the other imports work just fine):
# Program for OCR
import numpy as np
import cv2
from matplotlib import pyplot as plt
I find that sometimes after installing a module in PyCharm it requires a restart in order for it to work. Also, if you do want to do it in the command line, try pip3 install cv2.
I use matplotlib to create some charts, using the AGG backend.
import matplotlib
matplotlib.use('AGG')
import matplotlib.plot as plt
# ...
def chart_view(request):
fig = plt.figure
# Do stuff with fig and finally save it in a Django HttpResponse
# object and return the HttpResponse object.
Now I have a web page that has three images, all three images resulting in running chart_view. Only one image usually makes it, and the Django development server stops with "Fatal Python error: GC object already tracked". I'm not certain the problem is in matplotlib, it could be in pandas.
How can I debug the problem?
OK, I found out that it's doing it when I use Debian Jessie's matplotlib 1.4.2 in combination with the latest pandas (0.17.0) that I have installed with pip install --upgrade --no-deps pandas (in a virtualenv that uses --system-site-packages). If I use Debian's pandas 0.14.1 everything's fine. Go figure why this is. Anyway, using Debian's packages is what I intended to do so this solves the problem for me.