Working with Ubuntu 14.04
How to tell Sublime text 3 and SublimeREPL where to look for the python packages?
From my terminal, pip list returns a list with many python packages like that:
numexpr (2.2.2)
numpy (1.8.2)
oauthlib (0.6.1)
oneconf (0.3.7)
openpyxl (2.2.5)
PAM (0.4.2)
pandas (0.16.2)
However, inside Sublime text 3, on the console:
>>> import openpyxl
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'openpyxl'
>>> import pandas
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'pandas'
>>> import numpy
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'numpy'
From the SulbimeREPL console:
Python 3.3.6 (default, Jan 28 2015, 17:27:09)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pandas'
>>> import openpyxl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'openpyxl'
So, I assume that something needs to be set up.
You need to point SublimeRepl to the right interpreter.
Add to Settings -> Package Settings -> SublimeREPL -> Settings - User
{
"default_extend_env": {"PATH": "{PATH}:/usr/lib/python2.7"}
}
try this
python3 -m pip install --user openpyxl
Related
I have installed the pyproj.2.6.1 version, and I am using the python3.8.8; I can't correctly import the module query_utm_crs_info from pyproj package.
Here below the code :
from pyproj import Proj, Transformer, CRS
from pyproj.database import query_utm_crs_info
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyproj.database'
Similar problem with AreaOfInterest
from pyproj.aoi import AreaOfInterest
and I received this message
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyproj.aoi'
However, if I change it in to
from pyproj.transformer import AreaOfInterest
Any suggestions ?
https://pyproj4.github.io/pyproj/stable/api/database.html#pyproj.database.query_crs_info
query_crs_info was added in pyproj 3.
I am trying to use the forked version of python-gnupg: https://pypi.org/project/gnupg/
rather than the original: https://pypi.org/project/python-gnupg/
When I install "gnupg" to my conda environment I see this:
$conda list | grep gnupg
gnupg 2.2.17 he1f381d_0
but when I try to import that module, I get this not found error:
(my_env) $python
Python 3.7.7 (default, May 7 2020, 21:25:33)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gnupg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gnupg'
>>> import pretty_bad_protocol
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pretty_bad_protocol'
>>> from pretty_bad_protocol import gnupg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pretty_bad_protocol'
The docs for the forked version say to import gnupg and pretty-bad-protocol, but neither work for me. I can't figure out what I'm doing wrong. Has anyone else had success with this module? Thanks!
I used to use pyenv as my version manager but it had too much trouble installing packages so I'm moving over to virtualenv. So when I activate my virtual environment and write: which python I get:
/Users/kylefoley/codes/venv/bin/python
But when I actually use python it seems that it is still using pyenv. For example:
(venv) Admins-MacBook-Pro-4:~ kylefoley$ python
Python 3.8.0 (default, Nov 28 2019, 02:43:40)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Tk'
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Tkinter'
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kylefoley/.pyenv/versions/3.8.0/lib/python3.8/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I'm not trying to fix the problem of not being able to use Tkinter rather I just want to understand why this line:
File "/Users/kylefoley/.pyenv/versions/3.8.0/lib/python3.8/tkinter/__init__.py", line 36, in <module>
is coming up.
It's because I created the virtual environment when my version management was still pyenv. If I eliminate that version management, then I do not get the file pyenv.cfg but instead get the file: pip selfcheck.json which is located in the virtual environment directory together which lib, bin and include.
I have upgraded my ubuntu from 16.04 to 18.04 and then to 19.04. I've noticed that my virtualenvs stopped working and located the problem in distutils.
I've installed python3-distutils and I can run python3 > import distutils just fine, because this relates to python 3.7.
I can also do the same with python (2.7).
The problem is that a lot of my envs are python 3.6 where if I run import distutils I get:
Python 3.6.3 (default, Oct 6 2017, 08:44:35)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/emihir0/mjartan/lib/python3.6/distutils/__init__.py", line 25, in <module>
from distutils import dist, sysconfig
ImportError: cannot import name 'dist'
>>>
How can I resolve this?
The same goes for when I try to make a new venv through pycharm. I can make a new venv for both 3.7 and 2.7, but as soon as I try to make 3.6 I get:
Traceback (most recent call last):
File "/tmp/tmpb_tuwex1pycharm-management/setuptools-40.8.0/setup.py", line 11, in <module>
import setuptools
File "/tmp/tmpb_tuwex1pycharm-management/setuptools-40.8.0/setuptools/__init__.py", line 6, in <module>
import distutils.core
ModuleNotFoundError: No module named 'distutils.core'
And well, the main problem of course is that when I try to just run pip in my virtualenv, I get:
Traceback (most recent call last):
File "/home/emihir0/venv_name/bin/pip", line 7, in <module>
from pip._internal import main
File "/home/emihir0/venv_name/lib/python3.6/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/emihir0/venv_name/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/emihir0/venv_name/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/home/emihir0/venv_name/lib/python3.6/site-packages/pip/_internal/cli/cmdoptions.py", line 17, in <module>
from pip._internal.locations import USER_CACHE_DIR, src_prefix
File "/home/emihir0/venv_name/lib/python3.6/site-packages/pip/_internal/locations.py", line 10, in <module>
from distutils import sysconfig as distutils_sysconfig
File "/home/emihir0/venv_name/lib/python3.6/distutils/__init__.py", line 25, in <module>
from distutils import dist, sysconfig
ImportError: cannot import name 'dist'
EDIT:
I've fixed it by downgrading my python3-distutils to:
https://ubuntu.pkgs.org/18.04/ubuntu-main-i386/python3-distutils_3.6.5-3_all.deb.html
However, this is not a proper solution. How shall one fix this properly?
I'm using numpy for mathematical projects in python3. Today, I wanted to use numpy.integrate.quad, but you can see the errors and further attemps below. import numpy always works. So what's the matter?
$ python
Python 3.6.1 (default, Mar 27 2017, 00:27:06)
[GCC 6.3.1 20170306] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import numpy.integrate as integrate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy.integrate'
>>> import scipy.integrate as integrate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
>>> from numpy import integrate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'integrate'
>>> from scipy import integrate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
>>> from numpy.integrate import quad
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy.integrate'
>>> from numpy import integrate.quad
File "<stdin>", line 1
from numpy import integrate.quad
Numpy seems to be installed correctly, but I still can't use numpy.integrate. Am I messing with the imports?
from scipy.integrate import quad
numpy doesn't have an integrate package; those are in the scipy part of the delivery.