I'm using CLion 2017.1 and GDB for debugging. GDB compiled with python 2.7 support, but with no modules.
I wish to use matplotlib in order to plot some debug data (using GDB image watch) but there is no matplotlib presence. and no pip to install it.
I've tried to install pip using (gdb) python import get_pip but
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/user/temp/get_pip.py", line 28, in <module>
import tempfile
File "/home/user/clion-2016.3.4/bin/gdb/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "/home/user/clion-2016.3.4/bin/gdb/lib/python2.7/random.py", line 48, in <module>
from binascii import hexlify as _hexlify
ImportError: No module named binascii
Error while executing Python code.
So I don't know how to bootstrap instullation of additional modules into GDB's embedded python.
Any idea how to do that?
I've tried to install pip using (gdb) python import get_pip but
You need not install python modules from gdb shell. You can install them from command line as usual with your package manager or with pip. Make sure that you installed Python2 version of module. Once the module is installed you can use it in gdb embedded python:
$ gdb -q
(gdb) python
>import matplotlib
>end
(gdb)
Related
I have installed ecCodes library with
pip install eccodes
When I check it with 'pip list' it seems like it is installed as 0.9.7 ver but command:
python -m eccodes selfcheck
Returns error
RuntimeError: Could not load the ecCodes library!
The same error occurs when I try to import eccodes. I am using Windows 10 and Python 3.7.6
Any thougths what is wrong?
Full error:
import eccodes
Traceback (most recent call last):
File "<ipython-input-1-cfa7540a6bb2>", line 1, in <module>
import eccodes
File "C:\Users\admin1\anaconda3\lib\site-packages\eccodes\__init__.py", line 15, in <module>
from .eccodes import *
File "C:\Users\admin1\anaconda3\lib\site-packages\eccodes\eccodes.py", line 12, in <module>
from gribapi import __version__
File "C:\Users\admin1\anaconda3\lib\site-packages\gribapi\__init__.py", line 13, in <module>
from .gribapi import * # noqa
File "C:\Users\admin1\anaconda3\lib\site-packages\gribapi\gribapi.py", line 2217, in <module>
__version__ = grib_get_api_version()
File "C:\Users\admin1\anaconda3\lib\site-packages\gribapi\gribapi.py", line 2207, in grib_get_api_version
raise RuntimeError("Could not load the ecCodes library!")
RuntimeError: Could not load the ecCodes library!
The python package eccodes is only a binding to the C library eccodes made by ECMWF.
https://confluence.ecmwf.int/display/ECC/ecCodes+installation
As you can read on this website, they do not support Windows.
Advise from me: you won't get happy reading grib files (and working with meteorological data in general) on Windows. You could consider using Ubuntu or another Linux distro, maybe also just on a VM.
There is a conda package eccodes for the C library:
conda install -c conda-forge eccodes
Alternately, you can install those outside of your conda environment, for example, by compiling from source.
Then there is a pypi package eccodes that contains only the Python bindings:
pip install eccodes
You need both! From your error message, it seems that you have the Python bindings, but not the underlying C library.
For more (slightly dated) information, see the ECMWF Confluence wiki:
https://confluence.ecmwf.int/display/UDOC/How+to+install+ecCodes+with+Python+bindings+in+conda+-+ecCodes+FAQ
I tried to use the Coursera course downloader from here and it worked for few courses but not all. They have recommended to use Python3.X. So I uninstalled Anaconda (version 2) from my Mac and installed Python3.5.1 from Python's website but still the course downloaders did not work as it was using default Python 2.7.
So I deleted Python from /usr/local/lib and now nothing is working. When I do which python it shows ``usr/local/bin/pythonand bothpythonandpython3` runs.
But when I do pip install coursera it throws error as follows:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
And when I do sudo easy_install pip, I get the following error.
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
try Homebrew http://brew.sh/
brew install python3
curl bootstrap.pypa.io/get-pip.py | python3
Your Mac should have Python 2 and Python 3 installed by default. in the terminal "python" will launch Python2, "python3" will launch Python3. With Anaconda you could have just kept the Python 2 version and created an environment for Python 3, http://conda.pydata.org/docs/using/envs.html#managing-environments.
This is the solution you will most likely need, No module named pkg_resources. Setuptools is causing the issue and you will need to wget ez_setup.py. Reinstalling Anaconda will save you a lot of time and pain.
I am new in Python. I have trouble in my OSX.
My Python version
python --version
Python 2.7.8
My ipython version
IPython 2.3.0 -- An enhanced Interactive Python.
My OSX version
Yosemit 10.10.1
I am confused because some of my Python lib work well in console such as when I tried to import urllib but some of my Python libs also does not work in console. But all of my python packages work well in ipython.
When I tried in my console
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> import urllib
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>>
When I tried in my ipython console
In [1]: import numpy
In [2]: import urllib
In [3]: import matplotlib
In [4]:
Result of which python
users-MacBook-Pro:~ user$ which python
python is /opt/local/bin/python
python is /usr/local/bin/python
python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python
python is /usr/local/bin/python
python is /usr/bin/python
python is /usr/local/bin/python
users-MacBook-Pro:~ user$ which -a ipython
ipython is /Library/Frameworks/Python.framework/Versions/2.7/bin/ipython
Try to export python site packages PATH in your console
export PYTHONPATH="$PYTHONPATH:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"
Another way, add that path to .bash_profile file in your home directory. For more details read this documentation.
I have installed Kivy on my Mac. OS X comes installed with Python 2.7. I wanted to use the enum feature of Python 3, so I installed Python 3.4. After much searching and oulling of hair, I was pointed to this line
exec $(python -c "import os, sys; print os.path.normpath(sys.prefix)")/bin/python2.7 "$#"
in the file /Applications/Kivy.app/Contents/Resources/script. I changed it to:
exec /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 "$#"
in the hope of forcing Kivy to use Python 3.4.
I now get this error:
Traceback (most recent call last):
File "main.py", line 1, in <module>
from kivy.app import App
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/app.py", line 321, in <module>
from kivy.base import runTouchApp, stopTouchApp
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/base.py", line 29, in <module>
from kivy.event import EventDispatcher
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/event.py", line 8, in <module>
import kivy._event
ImportError: dlopen(/Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so, 2): Symbol not found: _PyString_Type
Referenced from: /Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so
Expected in: flat namespace
in /Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so
Can anyone help in fixing this error? Or is there a better way to get Kivy to use Python 3.4?
I have installed Kivy 1.8.0.
I am running the app from the terminal, e.g.
kivy main.py
This line:
dlopen(/Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so, 2)
Is trying to open a shared object, which would have been compiled for the explicit version of Python that your install of Kivy was intended for.
Any Python package that includes precompiled dependencies will only work for the version of Python they were compiled against.
Kivy has not yet been tested with Python 3.4. It runs fine with Python 3.3.
I've gotten kivy working on OSX El Capitan with Python 3.5. Here's how I did it.
You will need to brew install the dependencies, then modify setup.py to use the brew installed dependencies. The default setup.py will look to your frameworks directory, but that's not where brew puts the new files!
I was able to install kivy for python 3.5. I didn't have to do anything extra, just regular install kivy and it is working.
I've been troubleshooting for the past few days trying to install distribute so I can start importing 3rd party modules. I haven't used python for a couple years so I'm re-remembering everything which has been pretty difficult.
I followed the errors to the directories given but don't know what to do next.
I'm running a mac version 10.8.2 with python 3.2 running in Eclipse.
here's the code:
Traceback (most recent call last):
File "/Volumes/James Hard Drive/Python/Python_Lessons/3rd_Party_Stuff/easy_install.py", line 5, in <module>
from setuptools.command.easy_install import main
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/dist.py", line 6, in <module>
from setuptools.command.install import install
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/command/__init__.py", line 8, in <module>
from setuptools.command import install_scripts
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/distribute-0.6.28-py3.2.egg/setuptools/command/install_scripts.py", line 3, in <module>
from pkg_resources import Distribution, PathMetadata, ensure_directory
File "/Volumes/James Hard Drive/Python/Python_Lessons/3rd_Party_Stuff/pkg_resources.py", line 45
def _bypass_ensure_directory(name, mode=0777):
^
SyntaxError: invalid token
To install distribute (and pip, virtualenv):
#!/bin/bash
# download latest virtualenv.py
wget https://raw.github.com/pypa/virtualenv/master/virtualenv.py
# create a bootstrap virtual environment in ./venv directory
python3 virtualenv.py venv
To activate virtualenv:
$ . ./venv/bin/activate
Now you could use pip, easy_install to install other packages or use virtualenv-3.x to create new virtualenvs.
If you use many virtualenvs (different projects, different python versions); you could pip installvirtualenvwrapper to manage them easily e.g., workon/mkvirtualenv/rmvirtualenv commands.
The issue is that Python 3 interprets octal numbers differently than Python 2.x. In 2.x you could just prefix a number with a 0 to indicate that it is octal. In Python 3 you prefix it with 0o, so your number needs to be 0o777.
def _bypass_ensure_directory(name, mode=0o777):
See http://docs.python.org/release/3.0.1/whatsnew/3.0.html#integers for more details.
It is possible, that the file dist, is not to a recent version. Watch to this : https://pypi.python.org/pypi/distribute#uninstallation-instructions; and replace your folder normally in Python(version xxx)\scripts, by the highter version. It as raise this problem in my case, without all parse error on files describe before. Erase the previously version installed to finish.