dotenv installed, to be sure I check this by calling pip3 and pip3.7, despite that it's same
(env) slonocomp:-wrapper oleg$ pip3.7 freeze | grep dotenv
django-dotenv==1.4.2
python-dotenv==0.11.0
(env) slonocomp:wrapper oleg$ pip3 freeze | grep dotenv
django-dotenv==1.4.2
python-dotenv==0.11.0
(env) slonocomp:wrapper oleg$
version of p3 and p3.7 actualy the same
(env) slonocomp:wrapper oleg$ python3 -V
Python 3.7.4
(env) slonocomp:wrapper oleg$ python3.7 -V
Python 3.7.4
But when I try to import dotenv in interactive mode (for demonstration) I got differences
(env) slonocomp:wrapper oleg$ python3
Python 3.7.4 (default, Oct 12 2019, 18:55:45)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dotenv
>>>
(env) slonocomp:wrapper oleg$ python3.7
Python 3.7.4 (default, Oct 12 2019, 18:55:45)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dotenv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'dotenv'
>>>
(env) slonocomp:wrapper oleg$
The question is Why? And how to avoid this error.
Related
I have Ubuntu 18.04 and I have installed Miniconda and python 3.9
I have pytest installed and verify it like so:
which pytest
/usr/bin/pytest
When I try to import it from python I get the error: 'No module named 'pytest'
python3
Python 3.9.5 (default, Jun 4 2021, 12:28:51)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pytest'
How can I solve this?
You have pytest installed, but not in your conda env - /usr/bin/pytest is not a location that conda installs to. You need to install it by running
conda install -c conda-forge pytest
what is the difference between them?
/Library/Developer/CommandLineTools/usr/bin/python3
/usr/bin/python3
MacBook-Pro Desktop % whereis python3
/usr/bin/python3
MacBook-Pro Desktop % /usr/bin/python3 --version
Python 3.8.9
MacBook-Pro Desktop % /Library/Developer/CommandLineTools/usr/bin/python3 --version
Python 3.8.9
>python3
Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from my_custom_module.__main__ import main
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'my_custom_module'
But it works with other
>/Library/Developer/CommandLineTools/usr/bin/python3
>>>from my_custom_module.__main__ import main
it works
There is weird thing happens I mean, when I type full path I get 3.8.8 but when I type short name "python3" I get 3.7.9.
though
whereis returns as follow
MacBook-Pro Desktop % whereis python3
/usr/bin/python3
/usr/bin/python3
Python 3.8.9 (default, Aug 3 2021, 19:21:54)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
But
MacBook-Pro Desktop % python3
Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08)
[Clang 6.0 (clang-600.0.57)] on darwin
I think your confusion lies in the whereis command. whereis python3 doesn't actually tell you what will be run when you use python3, it just searches the standard binary directories for the specified program (python3). I would recommend using which instead, as it searches the actual PATH that you use.
See man page for whereis, man page for which, comparison.
For example on my personal computer:
❯ whereis python3
/usr/bin/python3
❯ which python3
/usr/local/bin/python3
❯ /usr/bin/python3 --version
Python 3.8.9
❯ /usr/local/bin/python3 --version
Python 3.9.7
❯ python3 --version
Python 3.9.7
Actually I already installed tensorflow by using
$ pip install tensorflow
and it works well when I use
$ python
Python 2.7.15 (default, Jul 23 2018, 21:27:06)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import tensorflow
>>>
but when I use python3 on command line
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>>
it shows an error, and it shows the same error when I use IDLE
use
pip3 install tensorflow
pip installs to default python directory. pip3 installs to python3
I wrote a basic Python 3 script that uses the Google Sheets API. It works on a system that defaults to Python 3 (Arch). I'm trying to run the same script on an Ubuntu 14.04 system, but I'm unable to load the apiclient library. I installed with the recommended
pip install --upgrade google-api-python-client
But I noticed I can only load the library in python 2.
Here's what I'm observing:
~ $ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from googleapiclient import discovery
>>> quit()
~ $ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from googleapiclient import discovery
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'googleapiclient'
Any advice?
The Googleapiclient is installed only on python2 (Which i guess is your default python version) not python3.
Install Googleapiclient in python3 env using the following:
pip3 install --upgrade google-api-python-client
python -m pip install --upgrade google-api-python-client
I'm new to Ubuntu (14.04). I just installed django using sudo pip install Django.
This is what is happening:
rpr#rpr-Inspiron-3521:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>>
rpr#rpr-Inspiron-3521:~$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'django'
>>>
What should I do to be able to use Django from Python3.4?
Just write:
sudo pip3 install Django
But better use virtualenv like Daniel said.
Reference
If you cannot run pip3 install it with the following:
sudo apt-get install python3-setuptools
sudo easy_install3 pip
pip is presumably installed for Python 2, not Python 3. You may have a version named pip3 that targets Py3.
However, it would be better to use a virtualenv.