On my Linux system two python versions are present 2.7 and 3.6. To use python 3.6. in my PYTHONPATH in .profile file I have kept /usr/local/lib64/python3.6/site-packages and /usr/local/lib/python3.6/site-packages at the top. and there is no entry of python 2.7 path. In my sys.path variable I can see the python2.7 path entries. (dont know how they appear)
now the issue is when I use docker-compose up command it gives me below error. docker-compose version is 1.29.2
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 7, in <module>
from compose.cli.main import main
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 22, in <module>
from ..bundle import get_image_digests
File "/usr/lib/python2.7/site-packages/compose/bundle.py", line 12, in <module>
from .config.serialize import denormalize_config
File "/usr/lib/python2.7/site-packages/compose/config/__init__.py", line 6, in <module>
from .config import ConfigurationError
File "/usr/lib/python2.7/site-packages/compose/config/config.py", line 13, in <module>
import yaml
File "/usr/local/lib64/python3.6/site-packages/yaml/__init__.py", line 284
class YAMLObject(metaclass=YAMLObjectMetaclass):
^
SyntaxError: invalid syntax
If I add python 2.7 site package path at the top of PYTHONPATH docker-compose works but other programs start failing. I dont want to use python 2.7 how can I use only python 3.6.
Please suggest.
Related
I just upgraded to Pop OS(Ubuntu) 20.04, which upgraded Python 3.7 to 3.8. Now I get this error below when I run sam (from the AWS SAM CLI). Solutions found online all had to do with making sure python3-distutils is installed. I have verified that python3-disutils is installed. /usr/lib/python3.8/distutils looks fine, just not getting picked up for some reason.
One thing I noticed is that in the traceback below, it's using the system-wide pip, while I have a later version of pip installed under my .local. I don't know if those two symptoms are related but looks like I'm missing some config somewhere so none of the 3.8 or user space stuff is picked up.
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pip/_internal/main.py", line 14, in main
from pip._internal.utils.entrypoints import _wrapper
File "/usr/lib/python3/dist-packages/pip/_internal/utils/entrypoints.py", line 3, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
I have the same issue on Debian Bullseye (or rather mixed Bullseye/Buster).
Package python3-distutils (3.8.6) contains module for Python 3.8 and 3.9 (!).
Old package (3.7.3) for Python 3.7. You have to choose.
My workaround is just copy module.
mkdir -p /usr/lib/python3.7/distutils
cp -a /usr/lib/python3.8/distutils/* /usr/lib/python3.7/distutils/
I have been trying to run a python file using rosrun command but unfortunately I am having this module not found error because of a package named rospkg. Until a day before yesterday, it was all working fine but yesterday, ubuntu18.04 has got some updates out of which an update for ubuntu base was also present, since that update I am having this error.
I have tried to check whether I have installed the respective python-rospkg and its says I already have the latest version. I have also using
echo $PYTHONPATH
to check the sourced paths and they are sourced correct, I am not sure whats causing this error.
the error is as follows
Traceback (most recent call last
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py",
line 5, in <module>
import roslib
File "/opt/ros/melodic/lib/python2.7/dist-
packages/roslib/__init__.py", line 50, in <module>
from roslib.launcher import load_manifest
File "/opt/ros/melodic/lib/python2.7/dist-
packages/roslib/launcher.py", line 42, in <module>
import rospkg
ModuleNotFoundError: No module named 'rospkg'
The shebang for my is as follows,
#!/usr/bin/python3
When i try to run the file by changing the shebang to
#!/usr/bin/python2.7
I get the following error
Traceback (most recent call last):
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py",
line 3, in <module>
import tensorflow as tf
ImportError: No module named tensorflow
I have installed tensorflow version 1.14 using pip installation. Can anyone please help me solving this error. Thanks in advance
edit:
I have manually tried to set the python path to /usr/lib/python2.7/dist-packages as when I tried to install python-rospkg, it says the its already instaled in that location. Doing that I am having error importing tensorflow and the error is
`Traceback (most recent call last):
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py", line
3, in <module>
import tensorflow as tf
File "/home/microbot/.local/lib/python3.6/site-
packages/tensorflow/__init__.py", line 22, in <module>
import inspect as _inspect
File "/usr/lib/python3.6/inspect.py", line 41, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/usr/lib/python3.6/tokenize.py", line 33, in <module>
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:`
Please can you help, I am trying to run a python script from Windows cmd. The error message I get is:
File "C:\Program Files (x86)\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\compat\__init__.py", line 48, in <module>
import __builtin__ as builtins
ModuleNotFoundError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\IndexTrader\code\futures_calc.py", line 16, in <module>
import pandas as pd
File "C:\Program Files (x86)\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "C:\Program Files (x86)\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\compat\__init__.py", line 61, in <module>
import http.client as httplib
File "C:\Program Files (x86)\WinPython\python3.6.5.amd64\lib\http\client.py", line 71, in <module>
import email.parser
I run the python script within Spyder and python and the code executes with no problem or errors.
I am not sure what builtin package it is referring to. I beleieve the issue is with the pandas package (which I uninstalled and reinstalled).
I have successfully run the script from cmd before, so I am not sure what the issue is. I have also reinstalled WinPython, but this has not helped.
I am not sure what to do, I checked the system paths and everything is in order, I also added a PYTHONPATH as a System variable, but no luck.
Any ideas?
When running django projects with python3 or installing modules with pip, I am getting google-appengine errors, even if my project is not using google appengine.
When running pip3 freeze I get the following results:
andrew#andrew:~/dev/quickistock$ pip3 freeze
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/home/andrew/.local/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/andrew/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 23, in <module>
from pip.locations import (
File "/home/andrew/.local/lib/python3.5/site-packages/pip/locations.py", line 10, in <module>
from distutils.command.install import install, SCHEME_KEYS # noqa
File "/usr/local/google-cloud-sdk/platform/google_appengine/lib/distutils/distutils/command/install.py", line 258
raise DistutilsOptionError, \
^
SyntaxError: invalid syntax
The file usr/local/google-cloud-sdk/platform/google_appengine/lib/distutils/distutils/command/install.py has lines like this and is compatible with python 2.1. Note. this is not the official google repository but it's accurate:
print "config vars:"
This means that install.py is a python 2 file and you are running pip from python 3. There probably is some incompatibility between them.
I have already have a virtual environment installation of Tensorflow on my computer, although it runs Python 2.7. Now I want to work with Tensorflow running in Python 3.5.
For Python 3, I've created a virtual environment since the default Python environment on my computer is Python 2.7. I'm attempting a Pip installation of Tensorflow in a Python 3 virtual environment that I have named py3k. The installation procedure throws errors that I'm finding difficulty in debugging.
Here's what I did:
anirudh#anirudh-Vostro-3445:~$ source activate py3k
(py3k) anirudh#anirudh-Vostro-3445:~$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl
(py3k) anirudh#anirudh-Vostro-3445:~$ sudo pip3 install --upgrade $TF_BINARY_URL
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
cp35 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl means C python 3.5
You have python 3.2 on your machine
I recommend installing Ubuntu 15.04