I recently changed my IDE from Spyder to PyCharm, as I felt Spyder used through Anaconda was somewhat bloated. The code below runs more or less fine in Spyder, but I'm having issues in PyCharm. The code runs smoothly up until the data frame gets put in the model(1.1).Observing the metadata(?) related to the file, it should be suitable for analysis.
Every other places I have looked have been dealing with wrong formatting for file import. Far as I can see, this isn't the case with me, as the data fram works fine prior to the model.
Things I have done with hopes of resolving the isse:
- Decreased the sample size from 100K to 50K to 10K to 1K
- Changed the project directory with the actual
- I reinstalled the following dependencies via conda contra pip: numpy, PyMC3, Theano
- I increased the VM to 100GB
- Installed new GPU driver for processing
- I added preprocessing thinking it might have something to do with that
The error that I keep getting when running the model is:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Greencom\miniconda3\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\Greencom\miniconda3\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\Greencom\miniconda3\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\Greencom\miniconda3\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\Greencom\miniconda3\lib\runpy.py", line 264, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Users\Greencom\miniconda3\lib\runpy.py", line 234, in _get_code_from_file
with io.open_code(decoded_path) as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\Greencom\\OneDrive\\Dokumenter\\Trading\\Quant\\Python Analysis\\<input>'
I cannot see where the file directory has any relevancy to the actual model, so I don't understand the counter argument.
How do I solve this?
from scipy import stats
import arviz as az
import numpy as np
import matplotlib.pyplot as plt
import pymc3 as pm
import seaborn as sns
import pandas as pd
from theano import shared
from sklearn import preprocessing
print ( 'Running on PyMC3 v{}'.format ( pm.__version__ ) )
# data import #
EU50p1d = pd.read_excel (
"C:\\Users\\Greencom/OneDrive\\Dokumenter\\Trading\\Quant\\Python Analysis\\CURRENCYCOM_EU501Dp.xlsx" )
# checking for 0-values #
EU50p1d.isnull ().sum () / len ( EU50p1d )
# Determining upper & lower value for model
lower = int ( EU50p1d.min () ) if int ( EU50p1d.min () ) == float ( EU50p1d.min () ) else float ( EU50p1d.min () )
upper = int ( EU50p1d.max () ) if int ( EU50p1d.max () ) == float ( EU50p1d.max () ) else float ( EU50p1d.max () )
# Gaussian Inferences #
az.plot_kde ( EU50p1d.close, rug=True )
plt.yticks ( [0], alpha=0 )
### 1.1 Model ##
with pm.Model() as model_g:
μ = pm.Uniform('μ' , lower=2375.7 , upper=3858.3)
σ = pm.HalfNormal('σ' , sd=100)
y = pm.Normal('y' , mu=μ , sd=σ , observed=EU50p1d.values)
trace_g = pm.sample(100000 , tune=1000)
/
and a lot of escaped\\
in your code - but the error message has all\\
and you've removed the actual filename from it for some reason and replaced it with<input>
even though the filename is still in the code. Can you please share the actual code and the full error message? Does the file actually exist at that location? Have you tried simply opening the same file from a test script that just doesopen('the_file_name', 'r')
to see if it's a simple IO or permissions issue?/
and it didn't alter the outcome. In addition, I couldn't find the escaped\\
you mentioned. But yes, the whole error will be added to OP. What you see above is the whole code. I tried open() and got the following:<_io.TextIOWrapper name='CURRENCYCOM_EU501Dp.xlsx' mode='r' encoding='cp1252'>
_main()
inspawn.py
. It ends up (bottom line of the error message) trying to open your.xlsx
file as it if were a python file (using.open_code()
). It's unclear why it would do that, but I would recommend simply creating a new virtual environment for your project and only installing the required packages to see if your code is fine otherwise. Apologies about the confusion about 'escape \\', I meant double backslash (i.e. escaped backslash)