for my homework we need to use jupyter notebook to run an .ipynb file. I use Mac and I used pip install jupyter to install it using terminal, which was successful. However when I tried to open it using the commandjupter notebook I get this error. Any ideas? Thanks.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/jupyter-notebook", line 5, in
from notebook.notebookapp import main
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/notebookapp.py", line 76, in
from .base.handlers import Template404, RedirectWithParams
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/base/handlers.py", line 24, in
import prometheus_client
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/init.py", line 3, in
from . import (
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 43, in
GC_COLLECTOR = GCCollector()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 14, in init
registry.register(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/registry.py", line 26, in register
names = self._get_names(collector)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/registry.py", line 66, in _get_names
for metric in desc_func():
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 36, in collect
collected.add_metric([generation], value=stat['collected'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/metrics_core.py", line 126, in add_metric
self.samples.append(Sample(self.name + '_total', dict(zip(self._labelnames, labels)), value, timestamp))
TypeError: new() missing 1 required positional argument: 'exemplar'
From your terminal out screen grab, I can see that you are not in a virtual environment which would mean that you are using global python.
Three things to check and or consider:
1. Python Version (management and checking).
To avoid the type of error that you are seeing- creating dependency issues of your versions of python, it may be an idea to use a package manager like conda or use virtual environments and install within them.
2. Proper use of pip install:
If you do not want to use vnev's or a package manager like conda perhaps double-check that you have installed on the correct version of python and install jupyter on the version of python you want to use.
python3.6 -m pip install jupyter
3. Environment Management:
There are a number of different options for managing the python version some people like to create virtual environments within your present working directory and active them using:
python3.6 -m pip install virtualenv
python3.6 -m venv env_name
source env_name/bin/activate
Once activated your terminal will show:
(env_name) jeffmpro....
You can then pip install jupyter inside this environment and this will then run using:
jupyter notebook
If you want to manage the python version and virtual environments globally using shims you can do this using a package called pyenv:
https://github.com/pyenv/pyenv
https://github.com/pyenv/pyenv-virtualenv
I would also use homebrew on mac to manage installations in the command line.
https://brew.sh/
Hope this helps :-)
The correct answer is actually what came out in the comments, I'll report it here for future viewers:
pip install jupyter
pip install notebook
jupyter-notebook your-file.ipynb
See you!
Related
Traceback (most recent call last):
File "D:\Anaconda3\envs\sklearn_tut.yml\Scripts\jupyter-script.py", line 10, in <module>
sys.exit(main())
File "D:\Anaconda3\envs\sklearn_tut.yml\lib\site-packages\jupyter_core\command.py", line 247, in main
command = _jupyter_abspath(subcommand)
File "D:\Anaconda3\envs\sklearn_tut.yml\lib\site-packages\jupyter_core\command.py", line 134, in _jupyter_abspath
'Jupyter command `{}` not found.'.format(jupyter_subcommand)
Exception: Jupyter command `jupyter-lab` not found.
I've run python -m ipykernel install --user --name=xxx and tried jupyter-lab and jupyter lab, both failed.
But later I installed jupyter notebook with conda create -n python36 python=3.6 and it ran just fine. I can't understand what went wrong.
In my opinion, Anaconda is best for the beginners. In my own experience with Anaconda, it reminded me of some of those PC anti-virus programs of years past which prevented me from performing many of my normal operation on the PC. Once I was prevented from doing what I wanted with the computer, then that software was immediately uninstalled.
Once it became apparent that Anaconda was interfering with what I intended, then I uninstalled Anaconda and the associated python installation(s). I reinstalled Python and then I used pip to install python packages and updates. I was doing the package management, which if I recall, Anaconda was interfering with my ability to use pip and making my control over python, virtual environments, etc.. difficult.
You can install the IRkernel without Anaconda. Here are the steps to perform using RStudio:
>install.packages("devtools") # install and then open library
>devtools::install_github("IRkernel/IRkernel") # can't recall, may need to open library
>IRkernel::installspec() # All done. Select a working director then type; 'Jupyter Lab'
IMO, everyone other than complete novices and neophytes, should be installing applications themselves and then doing the package management without using Anaconda.
I am writing because I am having trouble installing Pyomo using pip on Python 3.6 on Mac OSX 10.14
I'm following the installation instructions here.
I can successfully execute the first command:
pip install pyomo
But when I run into trouble when I'm supposed to run the following command to install additional dependencies:
pyomo install-extras
Running this command produces the following error:
Traceback (most recent call last):
File "/usr/local/bin/pyomo", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/pyomo/scripting/pyomo_main.py", line 82, in main
retval = _options.func(_options)
File "/usr/local/lib/python3.6/site-packages/pyomo/scripting/driver_help.py", line 46, in install_extras_exec
pyutilib.subprocess.run(command, tee=True)
File "/usr/local/lib/python3.6/site-packages/pyutilib/subprocess/processmngr.py", line 690, in run_command
th.join()
UnboundLocalError: local variable 'th' referenced before assignment
There is a post about this here on Google Groups but no solution yet.
This is a documented issue on the github for Pyomo: https://github.com/Pyomo/pyomo/issues/243
They don't appear to have solved the pip installation of pyomo extras.
However, if you have conda installed - https://docs.conda.io/en/latest/
You should be able to use the terminal commands from:
https://pyomo.readthedocs.io/en/latest/installation.html
run this in terminal after conda has been successfully installed:
conda install -c conda-forge pyomo.extras
I know this isn't pip, but it's at least a workaround until pyomo fixes their documentation.
confirmed working on python 3.x and ubuntu 18.04
I got the problem too (in Ubuntu 18.04).
Try installing it from the git project (https://github.com/Pyomo/pyomo):
In Ubuntu 18.04:
git clone https://github.com/Pyomo/pyomo.git
python3 pyomo/scripts/get_pyomo_extras.py
Use the corresponding commands for Mac OSX (I had never used it).
I hope that it works for you.
I am using windows 8 and python 3.6.1 I've done the following command in my cmd:
pip install cryptoshop
However, when I run the following python code:
from cryptoshop import encryptfile
from cryptoshop import decryptfile
result1 = encryptfile(filename="test", passphrase="mypassphrase", algo="srp")
print(result1)
result2 = decryptfile(filename="test.cryptoshop", passphrase="mypassphrase")
print(result2)
I get the following error:
Traceback (most recent call last):
File "C:/Users/Owner/Desktop/test.py", line 1, in
from cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop__init__.py", line 26, in
from cryptoshop.cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop\cryptoshop.py", line 56, in
from ._cascade_engine import encry_decry_cascade
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_cascade_engine.py", line 27, in
from ._nonce_engine import generate_nonce_timestamp
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_nonce_engine.py", line 39, in
import botan
ModuleNotFoundError: No module named 'botan'
Now, I obviously know that you must install botan into python in order to use it. However, this is where I am running into an issue. I've downloaded Botan from this link as instructed:
https://github.com/randombit/botan
And then I've followed these instructions in an attempt to install Botan:
./configure.py [--prefix=/some/directory]
make
make install
However, when I type make into the command line I get an error saying there is no such command. And then when I go to run my above Python code I still get the no module Botan error. So obviously I am doing something run. How can I properly install Botan into my Python 3.6 directories so that I can use cryptoshop.
I've also attempted to do pip install Botan, as that is how I've installed so many other python libraries but that has been unsuccessful as well.
make is a linux command
According to the botan website you can use nmake as a replacement on windows ( http://wiki.c2.com/?UsingNmake ) :
On Windows
You need to have a copy of Python installed, and have both Python and
your chosen compiler in your path. Open a command shell (or the SDK
shell), and run:
$ python configure.py --cc=msvc (or --cc=gcc for MinGW) [--cpu=CPU]
$ nmake
$ botan-test.exe
$ nmake install
Botan supports the nmake replacement Jom which enables you to run
multiple build jobs in parallel.
source : https://botan.randombit.net/manual/building.html
For completeness, here's how I made it work on a Mac
Assuming you have brew installed.
brew install botan
You may need to install other functionality first:
brew install gmp
brew install mpfr
brew install mpc
Find out where botan got installed with brew info botan.
My location is /usr/local/Cellar/botan/2.6.0
In that folder, you'll find lib/python2.7/site-packages, copy the contents of this folder into your Python's installation site-packages folder.
Note 1: At the time of this writing, only python 2.7 seems to be supported, but I'm using python 3.6 and everything seems to be working.
Note 2: If the file is called botan2.py, you may need to rename it to botan.py in your python's site-packages folder.
I use Mac OS, it has python 2.7 and python 3.4. I use the pip install command to to install scrapy in python 2.7. Buy I also use the pip3 install command to install scrapy in python3.4 too...
I read the official documents on scrapy.org, I know that the scrapy just support the python 2.7. When I use the command scrapy startproject tutorial, it will return the errow below.
How can I use the command scrapy startproject tutorial with python 2.7?
File "/Library/Frameworks/Python.framework/Versions/3.4/bin/scrapy", line 9, in <module>
load_entry_point('Scrapy==1.1.0dev1', 'console_scripts', 'scrapy')()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 122, in execute
cmds = _get_commands_dict(settings, inproject)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 46, in _get_commands_dict
cmds = _get_commands_from_module('scrapy.commands', inproject)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 29, in _get_commands_from_module
for cmd in _iter_command_classes(module):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 21, in _iter_command_classes
for obj in vars(module).itervalues():
AttributeError: 'dict' object has no attribute 'itervalues'
Installing scrapy with pip will put an executable file somewhere in your PATH. Since you installed it two times, the python2 version was probably overwritten. To find this file use the command which scrapy. To see the content of the file use cat $(which scrapy). It probably contains a line the reads something like this: #!/usr/bin/python3.4 causing it to use an incompatible version of python.
To fix this, uninstall the python3 version of scrapy.
pip3 uninstall scrapy
Then clean the command cache in bash by using hash -r or starting a new terminal session.
If the scrapy command still doesn't work you might have to reinstall the python 2 version of it as well.
pip install scrapy --force-reinstall
The solution there is, the developer had already provide the scrapy for Python3.x, so you can try the
$ pip install scrapy==1.1.0rc1
And the article is here
Actually you can use latest Scrapy to work with python 3.
I composed an article about installing Scrapy 3.1.1rc3 for Python3 on Windows and use it in Pycharm. I use Conda for package management and virtual enviroment. Conda works better than pip and easy_install for this job. It should work in Mac with minor changes.
I wish to use anaconda distribution of ipython, but typing ipython at the terminal produces an error message:
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: ipython==0.13.1
Adding PATH to .bash_profile as below produces the same error message. Asking which python produces //anaconda/bin/python, and which ipython produces /usr/local/bin/ipython. How can I fix this such that ipython launches anaconda ipython?
# MacPorts Installer addition on 2012-11-03_at_23:50:01: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
# Add colors to terminal
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# added by Anaconda 1.6.1 installer
export PATH="//anaconda/bin:$PATH"
export PATH=/anaconda//bin/isympy:$PATH
# added to Homebrew: bad command
export PATH=/usr/local/bin:$PATH
Update: I updated anaconda and ipython using conda update as suggested, but still get the same error message.
Update 2: Thanks for all the suggestions. I modified /usr/local/bin/ipython as follows:
#!//anaconda/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'ipython==1.1.0','console_scripts','ipython'
__requires__ = 'ipython==1.1.0'
import sys
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('ipython==1.1.0', 'console_scripts', 'ipython')()
)
Now which ipython produces //anaconda/bin/ipython, and ipython launches.
Your problem is in your $PATH. If you look at your traceback, it's running /usr/local/bin/ipython - this is the one that is installed by Homebrew, and not by Anaconda. (Anaconda installs everything into /anaconda/bin.)
The reason this is getting picked up is because the very last line of your .bash_profile sticks /usr/local/bin at the front of your path. This means that the ipython that you installed via Homebrew is masking the one that's installed by Anaconda.
You have two options:
Uninstall the ipython that Homebrew installed, and just use Anaconda for your Python packages.
In your .bash_profile, move the Homebrew PATH modification line above the Anaconda one. This way, Anaconda's ipython, python, and various other Python commands will take precedence.
Remember, if you change your .bash_profile, you need to close your Terminal and start a new one for the changes to take effect.
It looks like your path is completely ok. Notice that the error comes from "/usr/local/bin/ipython". It is not a bash error, it is more likely an error involving setup_tools, or pip, that is Python packaging tools. Bash finds ipython and executes ipython startup file but encounters an error there.
The error appears to be saying that your version of ipython is incompatible. Have you tried doing something like this?
conda update conda
conda update ipython
Updaing conda and ipython is recommended in iPython documentation. Perhaps this will fix the problem. If not, then add an information saying that you updated conda and ipython to your question.
One possible reason is that there are multiple ipython versions installed e.g., brew might install to /usr/local/bin, conda might install to /anaconda/bin (it is just a guess). The advice from similar issue is to remove all ipython installation completely and install the one that you will use.
Ensure you check the path to the Python executable specified at the start of the script. When I installed iPython it was defined as:
#!/usr/bin/python
Instead of:
#!/usr/local/bin/python
Hence the default OS X install of Python was being used instead of my brew installed version.
For me was slightly different because even with Anaconda installed wasn't able to find the command or to run ipython and wasn't able to find the PATH.
My solution was to run these commands:
nano ~/.bash_profile
export PATH="/anaconda3/bin:$PATH"
source ~/.bash_profile
and then to check conda version:
conda
and I update conda and ipython running:
conda update conda
conda update ipython
Hope this could help someone.
This helped me: https://stackoverflow.com/a/49925193/3351569