The IPYTHON documentation implies there is a way to modify the config file to include an additional path for templates.
Please advise. I have a template file which I want to use, with extension *.tpl which I do not want to have to move around to the local directory of where I do my work.
Any tips? I've searched everywhere and can't find this. It seems to only search the local directory where I am running the ipython nbconvert test.ipynb --to slides --template output_toggle_html.
Thanks.
In the ipython_nbconvert_config.py file located , you can enter the line c.TemplateExporter.template_path = ['.'] which will do the same as the default behavior, however you can add to this list. For example, the code below adds $IPYTHONDIR/nbextensions/templates and will search for *.tpl files in those locations, in the order in which they are provided in the list.
from os import environ
IPYTHONDIR = environ["IPYTHONDIR"]
template_rel_path = '/nbextensions/templates'
template_path = IPYTHONDIR + template_rel_path
c.TemplateExporter.template_path = [
'.',
template_path
]
Related
Hello i have one more problem with deploying my app by Streamlit. It works localy but when I want to upload it on git hub it doesnt work..Have no idea whats wrong. It seems that there is problem with path to the file:
"File "/app/streamlit/bobrza.py", line 14, in <module>
bobrza_locations = pd.read_csv(location)"
Here is link to my github repo. Will be very very grateful for help. Thank in advance.
https://github.com/Bordonous/streamlit
The problem is you are hard coding the path of the bobrza1.csv and route.csv to the path on your computer so when running the code on a different environment the path in not legal.
The solution is to make location independent from running environment, for this we will use the following:
__file__ variable - the path to the current python module (the .py file).
os.path.dirname() - a function to get directory name from path.
os.path.abspath() - a function to get a normalized absolutized version of path.
os.path.join() - a function to join one or more path components.
Now you need to change your location and location2 variables in the code to the following:
# get the absolute path to the directory contain the .csv file
dir_name = os.path.abspath(os.path.dirname(__file__))
# join the bobrza1.csv to directory to get file path
location = os.path.join(dir_name, 'bobrza1.csv')
# join the route.csv to directory to get file path
location2 = os.path.join(dir_name, 'route.csv')
Resulting in an independent path of the bobrza1.csv and route.csv.
In Magento 2, I have create new theme. I tried to add less file app/design/frontend/mage_vender/sample(theme)/web/css/source/_extend.less.
But it is not showing changes.
Please can anyone tell me, how can we do ?
I am using magento 2.1.3
Thank you
The first thing you need to do is to create your theme, don't forget to add all the required files like the theme.xml and registration.php. Last time I checked the magento 2 documentation it was up to date and had enough information regarding on how to create new themes.
Second thing you need to do is to add your new theme to the theme.js, other wise you will not be able to compile your new less files into CSS. You do this by adding a new json group into /dev/tools/grunt/configs/themes.js
Now to override less files for example lets says the _navigation.less you just need to put it under /app/design/frontend/[YOUR_THEME]/web/css/source/_navigation.less
Then do a grunt refresh, you do this always when you add new files and grunt watch if you're editing one that has already been added.
We have another way to do it.
First, create a new less file and then add it inside your _extend.less file like below.
#import 'theme/slick.less';
After that, if you use grunt then need to do the below things.
/dev/tools/grunt/configs/themes.js
<theme_name>: {
area: 'frontend',
name: '/',
locale: en_US,
files: [
'<path_to_file1>', //path to root source file ex: css/styles-m
'<path_to_file2>' ex: 'css/styles-l'
],
dsl: 'less'
After adding the above please run the below commands.
grunt clean:theme
grunt exec:theme
grunt less:theme
chmod 0777 -R var/*
chmod 0777 -R pub/*
chmod 0777 -R generated/*
grunt watch
Please check and let us know if you still facing any issues.
I am importing products using the built in CSV import (System - import - products)
All my data is imported fine, but I get an error
Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in rows: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
In my css I have written the base_image path as ://mywebsite.ca/pub/media/import/img/hose/jpg/Ach7938.jpg
as a test I removed my folder structure, edited the csv and tried this and got same problem, same error http://mywebsite.ca/pub/media/import/Ach7938.jpg
I tried writing file path as /pub/media/import/img/hose/jpg/Ach7938.jpg
but it won't let me past the "check data" validator.
I confirmed the permissions on the folders and files is 775
I am using PHP 5.6, I tried 7 but it broke the whole site in many different ways, so that isn't an option
As a side note, if I run this 20 times in a row, the entire site hangs and import won't work again until I do a full system restore (whats up with that?)
Can I put the images on a different server and link to them that way?
Image path can be relative path or simple name. I've imported with both and it worked. In my case issue was the images given in path wasn't available in folder. I tried it with importing available and not-available image and was getting error in case when that image wasn't available.
Path can be any one ,it isn't must to use pub/media/import only.
For the import images issue i have fixed the issue from Uploader.php file. change below file path code and success working import images.
File path:
magento/vendor/magento/module-catalog-import-export/Model/Import/Uploader.php
Find the below line from line number 201:
$filePath = $this->_directory->getRelativePath($filePath . $fileName);
Replace with:
$filePath = strpos($filePath, $fileName) !== false ?
$filePath:$this->_directory->getRelativePath($filePath . $fileName);
For More information refer to this GitHub link:
https://github.com/magento/magento2/pull/20761/commits/8612789375b0c173f0ba852c587882af6ff8bc7f
The Images File Directory needs to be set relative to the Magento doc root.
For example if your product images are in pub/media/catalog/product
Set that as your Images File Directory.
While trying to use the sphinx matlab domain I can't get the MWE to work, provided on the extensions pypi site
There is always this Can't import module error. I'd guess, that the extension kind of generates pseudo modules from the m-code, but up to know I actually could not figure out, how this mechanism works.
The dir structure looks like this
root
|--test_data
| |--MyHandleClass.m
|
|--doc
|--------conf.py
|--------Makefile
|--------index.rst
The files MyHandleClass.m and index.rst contain the example code given on the package site and the conf.py starts like this
import sys, os
sys.path.append(os.path.abspath('.'))
sys.path.append(os.path.abspath('./test_data'))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
"sphinxcontrib.matlab",
"sphinx.ext.autosummary",
"sphinx.ext.autodoc"]
autodoc_default_flags = ['members','show-inheritance','undoc-members']
autoclass_content = 'both'
mathjax_path = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default'
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
Error msg
WARNING: autodoc: failed to import module u'test_data'; the following exception was raised:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\sphinx\ext\autodoc.py", line 335, in import_object
__import__(self.modname)
ImportError: No module named test_data
E:\ME\doc\index.rst:13: WARNING: don't know which module to import for autodocumenting u'MyHandleClass' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)
After varying this and that maybe somebody out there has a clue?
Thanks for trying the matlabdomain sphinxcontrib extension. In order to use Sphinx to document MATLAB m-files, you need to add matlab_src_dir in conf.py as described in the Configuration section of the documenation. This is because the Python interpreter can't import a MATLAB m-file. Therefore you should not add your MATLAB root to the Python sys.path, or you will get the error you received. Instead set matlab_src_dir to the path containing the folder of your MATLAB project which you want to document.
Given your file structure, in order to document test_data use a conf.py with the following:
import os
# NOTE: don't add MATLAB m-files to `sys.path`
#sys.path.insert(0, os.path.abspath('.'))
# instead add them to `matlab_src_dir
matlab_src_dir = os.path.abspath('..') # MATLAB
Hope that does it! Please feel free to ask any more questions. I'm happy to help!
How to pass the location of .rpmmacros file in rpmbuild command ?
by default it try to look for it in home dir.
I tried -rcfiles /location/to/.rpmmacros but it gave me
error: missing ':' (found 0x2f) at /usr/local/.rpmmacros:1
content of .rpmmacros
%_topdir /usr/path/
Hmm... Am not an expert myself, but shouldn't it be --rcfil=location_to_rpmrc
And the rpmrc file should contain the path to rpmmacros in the format
macrofiles::full_path_to_rpmmacros_file
With RPM version 4.12.0.1, you can specify the rpmmacro file as follows:
rpmbuild --macros=<YOUR_LOCAL_MACRO> <YOUR_LOCAL_SPEC_FILE>
after replacing and with corresponding path to your files.