I am trying to launch ipython using the command: python -m ipython
When launched I get the following error : C:\Program Files\Python36\python.exe: No module named ipython
This is strange because when I run python -m pip show ipython, I get the following message :
Name: ipython
Version: 6.2.1
Summary: IPython: Productive Interactive Computing
Home-page: https://ipython.org
Author: The IPython Development Team
Author-email: ipython-dev#python.org
License: BSD
Location: c:\program files\python36\lib\site-packages
Requires: simplegeneric, setuptools, decorator, pickleshare, traitlets,
pygments, colorama, prompt-toolkit, jedi
I already ensured that all dependencies were correctly installed.
Could you please help me ?
It is actually spelled IPython (upper case I and P to start).
python -m IPython
will do.
Edit: confusion can arise because the pypi service allows the package name and module name to differ.
I solved this problem by using below command:
pip install IPython==5.0 --user
IPython version needs to pair with python version, and I have a python2.7
Related
I'm trying to install matplotlib library using pip from cmd (Windows 10), but the installation finishes after the download without actually installing the package. I don't get any error message, it just finishes.
cmd output:
C:\Users\username>pip install matplotlib
Collecting matplotlib
Using cached https://files.pythonhosted.org/packages/1a/c0/69e3f695d7384012e90be1e16570c08953baae00fd98094179ef87c7d5a2/matplotlib-3.1.1-cp37-cp37m-win_amd64.whl
C:\Users\username>
Trying without cached version doesn't help.
C:\Users\username>pip install --no-cache-dir matplotlib
Collecting matplotlib
Downloading https://files.pythonhosted.org/packages/1a/c0/69e3f695d7384012e90be1e16570c08953baae00fd98094179ef87c7d5a2/matplotlib-3.1.1-cp37-cp37m-win_amd64.whl (9.1MB)
100% |████████████████████████████████| 9.1MB 25.5MB/s
C:\Users\username>
I also tried downloading the .whl file and installing manually, same problem.
C:\Users\username\Downloads>pip install matplotlib-3.1.1-cp37-cp37m-win_amd64.whl
Processing c:\users\username\downloads\matplotlib-3.1.1-cp37-cp37m-win_amd64.whl
C:\Users\username\Downloads>
After all this matplotlib doesn't exist as an installed library. Other libraries are being installed and working fine without problems.
C:\Users\username\Downloads>pip show matplotlib
C:\Users\username\Downloads>
C:\Users\username\Downloads>pip show keras
Name: Keras
Version: 2.2.4
Summary: Deep Learning for humans
Home-page: https://github.com/keras-team/keras
Author: Francois Chollet
Author-email: francois.chollet#gmail.com
License: MIT
Location: c:\users\username\appdata\local\programs\python\python37\lib\site-packages
Requires: h5py, numpy, scipy, six, keras-applications, pyyaml, keras-preprocessing
Required-by:
I've done the whole exercise using pip3 also, the results are the same.
I've done this in cmd, powershell, and VSCode's powershell terminal as well, still same result.
Any idea what is happening here and how to solve it?
Note: I've replaced my user name with "username" in the cmd outputs.
Edit: I also tried installing a different version of matplotlib, but still getting the same result.
All I can think of is running this code from command line in the following order (Windows users):
python -m pip install -U pip
python -m pip uninstall matplotlib
This would pop the question: Proceed (y/n)?
y
python -m pip install matplotlib
I installed Ansible 2.8.2 using dnf on Fedora 30. I have an Ansible plug-in that requires a library. Using pip3 install I installed the required library.
When I run ansible-playbook directly, I see a ModuleNotFoundError for that module.
But if I run python3 /usr/bin/ansible-playbook, the module is found.
How can I get Ansible as installed by dnf to see this library?
Edit: further info: as installed from dnf, the main Ansible script has a shebang for /usr/bin/python3 -s. If I remove the -s, this problem is solved.
What's the benefit that the repo maintainers were seeking in adding this -s flag?
Is there a case to be made for asking the repo maintainers to omit the flag?
How can I get pip3 to install the library I need into a directory that will be seen when the -s flag is in effect?
Edit: Here's the output of ansible --version, and thanks for asking.
ansible 2.8.2
config file = /home/jdashton/proj/ansible-ccharacter/ansible.cfg
configured module search path = ['/home/jdashton/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.7.4 (default, Jul 9 2019, 16:32:37) [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
This is different from the suggested duplicate question because that question describes a "remote" task being run on localhost, in which case Ansible uses the default "remote" python interpreter. In this question, the library is being called from a local plugin, under Ansible's own python process. The -s flag in the shebang line at the top of the /usr/bin/ansible script is preventing Ansible from seeing some local libraries.
Edit: Following the suggestion from #zigarn I tried removing the library and reinstalling it as root. This resulted in the library being reinstalled into the same directory /usr/local/lib/... as before. Is there a way to get pip3 to install into the system library?
Here are the commands I attempted:
# pip3 uninstall tenacity
Uninstalling tenacity-5.0.4:
Would remove:
/usr/local/lib/python3.7/site-packages/tenacity-5.0.4.dist-info/*
/usr/local/lib/python3.7/site-packages/tenacity/*
Proceed (y/n)? y
Successfully uninstalled tenacity-5.0.4
# pip3 install tenacity
Collecting tenacity
Using cached https://files.pythonhosted.org/packages/6a/93/dfcf5b1b46ab29196274b78dcba69fab5e54b6dc303a7eed90a79194d277/tenacity-5.0.4-py2.py3-none-any.whl
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3.7/site-packages (from tenacity) (1.12.0)
Installing collected packages: tenacity
Successfully installed tenacity-5.0.4
# pip show tenacity
Name: tenacity
Version: 5.0.4
Summary: Retry code until it succeeeds
Home-page: https://github.com/jd/tenacity
Author: Julien Danjou
Author-email: julien#danjou.info
License: Apache 2.0
Location: /usr/local/lib/python3.7/site-packages
Requires: six
Required-by:
Also, for clarity, here is the source for the Ansible installation:
# dnf list ansible
Last metadata expiration check: 0:09:48 ago on Mon 12 Aug 2019 11:12:58 AM EDT.
Installed Packages
ansible.noarch 2.8.2-1.fc30 #updates
According to the documentation -s option of python is "Don’t add the user site-packages directory to sys.path."
So I would guess that you did pip3 install as your user instead as root, so the library was installed at your user side instead of system wide.
Try to reinstall the library with pip3 as root and it should be ok.
I am facing a strange problem which I could track down to the python logging package. Let me shortly explain what I want to do: the goal is to create html reports with python. I am using the R rmarkdown package which runs python code trough reticulate using a local virtualenv.
The Problem:
As soon as I install the python logging package rmarkdown runs into a problem when loading matplotlib. I have written a small test script to reproduce the example.
My system:
Ubuntu 18.04 bionic
Python 2.7.15rc1
Test "1" script (without logging):
Create a new virtualenv (venv).
Use venv/bin/pip to install matplotlib.
Run reticulate::import (at the end via rmarkdown::render).
Test "2" script (with logging):
Create a new virtualenv (venv).
In addition to the first test: install logging via venv/bin/pip.
Use venv/bin/pip to install matplotlib.
Run reticulate::import (at the end via rmarkdown::render).
The modules installed (virtualenv):
backports.functools-lru-cache 1.5
cycler 0.10.0
kiwisolver 1.0.1
logging 0.4.9.6 <- only for "test 2"
matplotlib 2.2.3
numpy 1.15.1
pip 18.0
pkg-resources 0.0.0
pyparsing 2.2.0
python-dateutil 2.7.3
pytz 2018.5
setuptools 40.2.0
six 1.11.0
subprocess32 3.5.2
wheel 0.31.1
The system site packages do have the same module version.
Results:
All tests from test 1 (without logging) work nicely.
The tests from test 2 (with loging) fail when using the virtualenv. When calling rmarkdown::render (see below), when using the system python installation (not virtualenv) they work nice as well.
There seem to be something strange with reticulate when logging is installed in a virtualenenv.
The output of the test script (see below):
The full output including the error:
----------- no logging package installed ------------
Module(matplotlib)
Module(matplotlib)
--------- with logging package installed ------------
Error in py_module_import(module, convert = convert) :
AttributeError: 'module' object has no attribute 'NullHandler'
Detailed traceback:
File "/home/retos/Downloads/venvtest/venv/lib/python2.7/site-packages/matplotlib/__init__.py", line 168, in <module>
_log.addHandler(logging.NullHandler())
Calls: <Anonymous> -> py_module_import -> .Call
Execution halted
Module(matplotlib)
The Module(matplotlib) output is the success message of loading the module via reticulate::import. As one can see only the one test fails where the virtualenv is used with installed logging python module.
Anyone having an idea what could case these problems? I spent quite some time to identify the source of the error, but I am kind of lost now ...
Test script to reproduce the error:
Here is a small bash/shell script to reproduce my tests.
#!/bin/bash
# New virtual environment and install matplotlib
echo " ----------- no logging package installed ------------"
if [ -d venv ] ; then rm -rf venv ; fi
virtualenv venv &>/dev/null > /dev/null
venv/bin/pip install matplotlib > /dev/null
# Print installed packages
Rscript -e "reticulate::use_python('venv/bin/python'); reticulate::import('matplotlib')"
Rscript -e "reticulate::import('matplotlib')"
# New virtual environment and install logging and matplotlib
echo " --------- with logging package installed ------------"
if [ -d venv ] ; then rm -rf venv ; fi
virtualenv venv > /dev/null
venv/bin/pip install logging > /dev/null
venv/bin/pip install matplotlib > /dev/null
# Print installed packages
Rscript -e "reticulate::use_python('venv/bin/python'); reticulate::import('matplotlib')"
Rscript -e "reticulate::import('matplotlib')"
I first thought it is related to the problem "ImportError: cannot import name cbook" but the solution there did not work.
May thanks in advance!
R
Logging became a standard module included in Python library in version 2.3. You must not install it from PyPI. Remove it ASAP:
pip uninstall logging
I get illegal instruction (core dumped) after running import tensorflow with version of tensorflow 1.7.
After that I installed tf 1.5.0-gpu (pip3 install --upgrade tensorflow-gpu==1.5.0)
Then tried to import tensorflow, I get no error
However tf.set_random_seed(random_state) - returns AttributeError: module 'tensorflow' has no attribute 'set_random_seed'
Then in the jupyter notebook with shit-tab get library help:
Type: module
String form: <module 'tensorflow' (namespace)>
Docstring: <no docstring>
Seems to isnt righ. However :
~ $ pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.5.0
Summary: TensorFlow helps the tensors flow
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: /home/analyst/anaconda3/lib/python3.6/site-packages
Requires: absl-py, wheel, six, tensorflow-tensorboard, numpy, protobuf
Required-by:
$ pip show tensorflow #Returns nothing
What might be wrong?
UPD: I have such files, which can be found via search. Im afraid of 1.1.0 tf. Is it okay?
>qqusr#qqusr-PC ~ $ locate -i tensorflow.py
/home/qqusr/anaconda3/pkgs/tensorflow-1.1.0-np112py36_0/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py
/home/qqusr/tensorflow/tensorflow/tools/dist_test/scripts/k8s_tensorflow.py
upd: I have 2 active namaspaces: how to fix that:
> tf.__path__
_NamespacePath(['/home/aa/tensorflow', '/home/aa/anaconda3/lib/python3.6/site-packages/tensorflow'])
1) One method that worked for #JaeDukSeo was using the precomplied version
https://www.lfd.uci.edu/~gohlke/pythonlibs/#tensorflow
In addition you give this a try and for precomplied GPU version: https://github.com/mind/wheels.
2) However, installing precomputed version leads me to another error, problems with intel libraries. Trying to solve such problem I found the solution
conda install -c anaconda tensorflow-gpu
You can specify here version you want to install as well
I am getting ImportError: No module named _pluggy error when running tests using pytest.
Then I tried installing pluggy using pip install pluggy. It installs pluggy==0.6.0 successfully, but is still giving the error.
Versions List (From running pip freeze | grep pytest)
pytest==3.3.1
pytest-cov==2.5.1
pytest-metadata==1.5.0
pytest-runner==3.0
pluggy==0.6.0
Python 2.7.12
Shown below is the stack trace
Tests run successfully when run in a virtualenv. What are the possible causes which can cause this error in a non-virtualenv environment?
As it was pointed out by #bouteillebleu the issue was in pytest-metadata package.
The solution was to upgrade the package
pip install --upgrade pytest-metadata