I would like to use the IPython interpreter in Eclipse/PyDev.
PyDev however does not recognize my IPython installation.
The results I get is the following:
>>> import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
PyDev console: using default backend (IPython not available).
D:\QuantumGIS\apps\Python25\python.exe 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
>>> import IPython
>>>
The "import IPython" command does work.
I'm using
Windows XP 32 bit
Eclipse 3.7.2
PyDev 2.4.0
IPython 0.10.2
Python 2.5 (version that is supplied with QGIS 1.7.3)
How should I set up PyDev so I can use IPython as the interactive interpreter?
Not sure if it's the same issue but from Fabio's blog he said to try in the python console (import IPython worked ok):
from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
which gave me nothing useful and:
from IPython.frontend.prefilterfrontend import PrefilterFrontEnd
Which complained that twisted wasn't installed. I installed twisted 12.0 for Python 2.5 and it's dependency Zope (3.8 for Python 2.5), restarted the IDE and the console now shows ipython. There was something about ipython actually using XMLRPC to communicate with the IDE so I guess twisted is needed for that.
Hope that helps.
Stu.
Windows 7
Aptana studio 3.1.2 (version of eclipse)
PyDev 2.5.0 IPython 0.10
Python 2.5 (needed for some old code I'm working on and haven't
upgraded yet)
Related
I am new to pytest and tried to write a first test case. Since I am new to programming overall, I developed without a virtual environment (naughty, naughty) using the globally installed python version 3.9.13.
The structure of my program is like this:
mypkg/
sub_mypkg/
file_a.py
pytest.ini
testing/
__init__.py
test_a.py
in which file_a.py imports pandas among other modules. The tests in test_a.py try among other things to run file_a.py.pytest.ini adds the root_dir to the PYTHONPATH.
In this setup pytest ran smoothly without any errors.
I then installed a virtualenv using python 3.11 in this project and installed all necessary modules (including pytest) in it and uninstalled pytest globally. After activating the virtualenv and running pytest from the terminal a ModuleNotFoundError was thrown for pandas.
Here is a list of the modules I use in venv:
Package Version
--------------- -------
attrs 22.1.0
colorama 0.4.6
contourpy 1.0.6
cycler 0.11.0
et-xmlfile 1.1.0
exceptiongroup 1.0.4
fonttools 4.38.0
iniconfig 1.1.1
kiwisolver 1.4.4
matplotlib 3.6.2
numpy 1.23.4
openpyxl 3.0.10
packaging 21.3
pandas 1.5.1
Pillow 9.3.0
pip 22.3.1
pluggy 1.0.0
pyparsing 3.0.9
pytest 7.2.0
python-dateutil 2.8.2
pytz 2022.6
PyYAML 6.0
setuptools 56.0.0
six 1.16.0
tomli 2.0.1
I checked that pandas was installed and I could import pandas in the REPL.
Also I could run the test line by line in the REPL.
Furthermore, I checked that the problem was not pandas itself. If I changed the placement of the import pandas with for example import numpy in file_a.py, it threw the ModuleNotFoundError for numpy.
I tried to use different versions of python in my venv (python 3.11.0, 3.10.7, 3.9.13, 3.9.6). Interestingly, pytest ran only inside the venv for python 3.9.13 (The one I developed it in).
I tried to include and delete __init__.py files in all directories and also tried different versions of pytest (6.2.5, 7.0.0).
I checked sys.path that the right root_dir was included.
Thanks in advance for your answers!
The Jupyter docs recommend using conda to install jupyter, if the runtime python is version 3.5 or lower. Installation is pretty straightforward with conda.
Follow Anaconda’s instructions for downloading and installing the Python 3.5 version.
$ conda install jupyter
$ pip list | grep ipython
ipython 7.29.0
ipython-genutils 0.2.0
$ ipython notebook --ip=0.0.0.0
This question is to discover if it's possible to install a 3.5 compatible jupyter using only pip, and without conda.
Given the following environment:
$ python --version
Python 3.5.2
$ sudo apt-get install python3-pip
$ pip3 --version
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
Installing ipython is possible with the following restrictions:
$ python3 -m pip install ipython==7.9 traitlets==4.3.3 jedi==0.17.2
Jupyter, however, doesn't install gracefully.
The following allows for installation:
pip3 install jupyter ipython==7.9 traitlets==4.3.3 jedi==0.17.2 pyzmq==20 argon2-cffi==21.1.0
But at runtime, jupyter crashes:
File "/home/vagrant/.local/lib/python3.5/site-packages/ipython_genutils/importstring.py", line 31, in import_item
module = __import__(package, fromlist=[obj])
File "/home/vagrant/.local/lib/python3.5/site-packages/notebook/__init__.py", line 27, in <module>
from .nbextensions import install_nbextension
File "/home/vagrant/.local/lib/python3.5/site-packages/notebook/nbextensions.py", line 15, in <module>
from jupyter_core.paths import (
File "/home/vagrant/.local/lib/python3.5/site-packages/jupyter_core/__init__.py", line 1, in <module>
from .version import version_info, __version__
File "/home/vagrant/.local/lib/python3.5/site-packages/jupyter_core/version.py", line 21
_suffix_ = f'.dev{version_info.serial}'
Is it possible to install a 3.5 friendly jupyter using pip?
Resources
pyzmq https://github.com/jupyter/notebook/issues/5961
iPython Versions
https://github.com/ipython/ipython/blob/master/README.rst
IPython 7.10+ supports Python 3.6 and above.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Python 3.3 and 3.4 were supported up to IPython 6.x.
Python 3.5 was supported with IPython 7.0 to 7.9.
traitlets vs. python 3.5
Traitlets 5 uses f-strings in code, not compatible with Python 3.5
uninstall the traitlets 5.0.3 version, and install 4.3.3 version
https://githubmemory.com/repo/ipython/traitlets/issues/620
argon2-cffi vs. python 3.5
https://packagegalaxy.com/python/argon2-cffi
It targets Python 3.6 and newer, and PyPy3.
The last version that works with Python 2.7 is 20.1.0, and the last version that works with Python 3.5 is 21.1.0.
jedi vs. python 3.5
https://jedi.readthedocs.io/en/latest/docs/changelog.html
0.17.2 (2020-07-17)
This will be the last release that supports Python 2 and Python 3.5. 0.18.0 will be Python 3.6+.
If I invoke ipython and ipython3, both show exactly the same message:
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
Is not it that ipython shows something like Python 2?
How can I make ipython use Python 2?
IPython 6+ requires Python 3.3+, so that's what it defaults to, and it will not open Python 2.x.
From the 6.x Series page in the IPython docs:
Important
This documentation covers IPython versions 6.0 and higher. Beginning
with version 6.0, IPython stopped supporting compatibility with Python
versions lower than 3.3 including all versions of Python 2.7.
If you are looking for an IPython version compatible with Python 2.7,
please use the IPython 5.x LTS release and refer to its documentation
(LTS is the long term support release).
I'm using Eclipse kepler & pydev 3.4.1 on Ubuntu 12.04.
I installed ipython 0.12.1 via pip, which was located in /usr/lib/python2.7/dist-packages/, so I added this path to PYTHONPATH via eclipse->preference->PyDev->Interpreters->Python Interpreter->System PYTHONPATH.
By this way, I would start IPython in the interactive console(just press CTRL_ALT_ENTER), the output is :
Python 2.7.3 (default, Feb 27 2014, 20:00:17) Type "copyright",
"credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python. ? ->
Introduction and overview of IPython's features. %quickref -> Quick
reference. help -> Python's own help system. object? -> Details
about 'object', use 'object??' for extra details.
PyDev -- Python IDE for Eclipse For help on using PyDev's Console see
http://pydev.org/manual_adv_interactive_console.html
It looks fine, but when I try to run a simple code in the interactive console, say:
from common_function import *
if __name__ == '__main__':
print("hello")
It shows me an ImportError:
File "/git/mycode/python_lab/pylab/simple_test.py", line 7, in
from common_function import *
ImportError: No module named common_function
Here, the simple_test.py and common_function.py are placed in the same src folder, and I find some posts on stackoverflow saying that adding the src folder which contatins all the py files to project's PYTHONPATH would solve this problem, so I tried and it did solve the ImportError, but the IPython is disable, the output of interactive console is :
/usr/bin/python2.7 2.7.3 (default, Feb 27 2014, 20:00:17) [GCC 4.6.3]
PyDev console: using default backend (IPython not available).
runfile('/media/data/yanglin/local/work/git/mycode/python_lab/pylab/simple_test.py')
hello
Any one know how to fix this problem?
I have Pydev 2.7, Python 3.2 and IPython 0.13 installed.
However, when I run the interactive console in Eclipse it says
PyDev console: using IPython 0.11
I cannot imagine where IPython 0.11 is supposed to come from. How can I check?
After running the console, import IPython; IPython.__version__ also gives me the correct version 0.13.
Is it IPython 0.13 in the console now or is something wrong?
I think you're fine. I tried
IPython.__version__
and also get 0.13 in the PyDev console:
import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
C:\Python27\python.exe 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
PyDev console: using IPython 0.11
import IPython
IPython.__version__
Out[1]: '0.13.1'