Closed johann-petrak closed 3 years ago
conda create --name nbdev python=3.8
conda activate nbdev
conda install -c fastai nbdev
nbdev_new nbdev_example
Creating project as above works for me.
Also:
❯ nbdev_new --help
usage: nbdev_new [-h] [--template_git_repo TEMPLATE_GIT_REPO] [--xtra XTRA] name
Create a new nbdev project with a given name.
positional arguments:
name A directory to create the project in
optional arguments:
-h, --help show this help message and exit
--template_git_repo TEMPLATE_GIT_REPO
url to template repo (default: https://github.com/fastai/nbdev_template.git)
--xtra XTRA Parse for additional args
Hope it helps.
As I said I installed nbdev using pip as the README suggests should be possible.
I did this again now using a new conda environment with Python 3.8 and after pip install nbdev
I got nbdev version 1.1.11 which no does not work in a different way:
nbdev_new mynbdev1
Gives me:
usage: nbdev_new [-h]
nbdev_new: error: unrecognized arguments: mynbdev1
nbdev_new --help
gives:
usage: nbdev_new [-h]
Create a new nbdev project from the current git repo
optional arguments:
-h, --help show this help message and exit
nbdev_new
without any argument gives inside a git repo that has a remote URL defined gives:
Traceback (most recent call last):
File "/home/johann/software/anaconda/envs/nbdev/bin/nbdev_new", line 8, in <module>
sys.exit(nbdev_new())
File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/fastcore/script.py", line 105, in _f
tfunc(**merge(args, args_from_prog(func, xtra)))
File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/nbdev/cli.py", line 99, in nbdev_new
else: urlsave(f'{FILES_URL}00_core.ipynb')
File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/fastcore/net.py", line 145, in urlsave
Path(name).write_bytes(res)
File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/pathlib.py", line 1240, in write_bytes
view = memoryview(data)
TypeError: memoryview: a bytes-like object is required, not 'str'
nbdev_new
without any arguments inside a git repo without a remote URL gives:
Traceback (most recent call last):
File "/home/johann/software/anaconda/envs/nbdev/bin/nbdev_new", line 8, in <module>
sys.exit(nbdev_new())
File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/fastcore/script.py", line 105, in _f
tfunc(**merge(args, args_from_prog(func, xtra)))
File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/nbdev/cli.py", line 85, in nbdev_new
url = run('git config --get remote.origin.url')
File "/home/johann/software/anaconda/envs/nbdev/lib/python3.8/site-packages/fastcore/xtras.py", line 174, in run
if res.returncode: raise IOError(stdout)
OSError
When instead installing nbdev using conda, I get version 0.2.40 and things seem to work.
So the main problem is that in various places the documentation/README says one can install nbdev using pip when in fact the pip package seems to be very outdated.
The pip package should get updated or the documentation should explicitly point out that pip does not contain the most recent version / should be avoided.
Since I often prefer to install all packages using pip, rather than deal with conda packages from all kinds of different conda channels plus stuff that is only available via pip, I would prefer the first solution.
@jph00 We have to change nbdev_new
to use the theme as well. Will look into this today also
I was able to reproduce this issue with the following steps:
gh repo create <user-name>/new-test-repo
cd new-test-repo
nbdev_new
Got the following error message
Traceback (most recent call last):
File "/Users/hamelsmu/anaconda3/bin/nbdev_new", line 33, in <module>
sys.exit(load_entry_point('nbdev', 'console_scripts', 'nbdev_new')())
File "/Users/hamelsmu/github/fastcore/fastcore/script.py", line 105, in _f
tfunc(**merge(args, args_from_prog(func, xtra)))
File "/Users/hamelsmu/github/nbdev/nbdev/cli.py", line 99, in nbdev_new
else: urlsave(f'{FILES_URL}00_core.ipynb')
File "/Users/hamelsmu/github/fastcore/fastcore/net.py", line 145, in urlsave
Path(name).write_bytes(res)
File "/Users/hamelsmu/anaconda3/lib/python3.8/pathlib.py", line 1240, in write_bytes
view = memoryview(data)
TypeError: memoryview: a bytes-like object is required, not 'str'
cc: @jph00 this is probably a high priority thing to work on, will try to address this on Monday
Should be fixed now if you install the latest fastcore
I first tried to use
nbdev_new
according to the tutorial which says it will create a new project and init a git repo. Sadly the tutorial does not say if it will create a new dir or expect to be inside an empty dir, nor does --help provide any more information.This gave me the following exception:
I then found isse #307 so I cloned some existing repo, changed into the directory and ran
nbdev_new
in there. This gave me the following exception:So I could not find any way at all to initialize a nbdev repo locally.
Installed nbdev (got 1.1.6) using pip under anaconda with python 3.8 on Ubuntu 20.04.