i'm new to coding and hoping to get some advice. I am using macOs Big Sur Version 11.4
I am trying to install a package called twarc and ran the following within my terminal.
pip install twarc
when I run pip show twarc
I see the following:
**Name: twarc
Version: 2.1.2
Summary: Archive tweets from the command line
Home-page: https://github.com/docnow/twarc
Author: Ed Summers
Author-email: ehs#pobox.com
License: UNKNOWN
Location: /Users/cominocomputer/opt/anaconda3/lib/python3.8/site-packages
Requires: click, click-config-file, requests-oauthlib, click-plugins, python-dateutil
Required-by:**
whenever I run pip2 show twarc I see the following error:
File "/usr/local/bin/pip2", line 11, in <module>
load_entry_point('pip==21.1.2', 'console_scripts', 'pip2')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2843, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2434, in load
return self.resolve()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2440, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Python/2.7/site-packages/pip-21.1.2-py2.7.egg/pip/__init__.py", line 1, in <module>
from typing import List, Optional
ImportError: No module named typing
What I assume to be the error is that I have Python2 and Python3 installed. I also have pip2 and pip3. Twarc got installed into pip3 but is not working properly when I try to run a python file because perhaps my file is running on pip2?
Does anyone know how to resolve this issue?
I have tried pip2 install typing this does not resolve the issue.
Below is an image of the error i get in IDLE when trying to use "import twarc" within my .py
based on you module name in python registry name is [twarc][https://pypi.org/project/twarc/2.1.2/]
you should do pip install twarc==2.1.2
Related
I might have multiple problems here but they both deal with virtualenv and python3 (3.6.13).
Problem 1:
I had installed virtualenv==20.14.1.
However, it's complaining that there's a version conflict for some reason.
$ python3 -V
Python 3.6.13
$ virtualenv -h
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 573, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 891, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 782, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (virtualenv 20.14.1 (/home/mylogin/.local/lib/python3.6/site-packages), Requirement.parse('virtualenv==15.0.1'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3266, in <module>
#_call_aside
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3241, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3279, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 575, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 588, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 777, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'virtualenv==15.0.1' distribution was not found and is required by the application
$
Problem 2:
I downgraded virtualenv to be 15.0.1 like it said it needed but then it complains that there's a missing module called dataclasses. For some reason, my co-workers don't have this problem but we can't figure out what is different between my setup and their setup.
$ virtualenv mydir -p python3.6
Running virtualenv with interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in /tmp/mydir/bin/python3.6
Also creating executable in /tmp/mydir/bin/python
Installing setuptools, pip, wheel...done.
/tmp/mydir$ source bin/activate
(mydir) myhost:/tmp/mydir$ python -V
Python 3.6.13
(mydir) myhost:/tmp/mydir$ python -m pip -V
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/mydir/lib/python3.6/site-packages/pip/__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "/tmp/mydir/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/tmp/mydir/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/tmp/mydir/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/tmp/mydir/lib/python3.6/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/tmp/mydir/lib/python3.6/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/tmp/mydir/lib/python3.6/site-packages/pip/_internal/configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "/tmp/mydir/lib/python3.6/site-packages/pip/_internal/exceptions.py", line 14, in <module>
from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
File "/tmp/mydir/lib/python3.6/site-packages/pip/_vendor/rich/console.py", line 7, in <module>
from dataclasses import dataclass, field
ModuleNotFoundError: No module named 'dataclasses'
This seems to be a chicken and the egg problem. I would run pip to install this missing module but pip is the program that is complaining about this missing module so I can't install it. Like I said above, none of my co-workers I asked know what the problem is.
For debugging purposes, I installed python 2.7.12 and virtualenv==20.14.1 to see what would happen. Apparently things work fine with python 2.7.
$ pip freeze | grep virtual
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
virtualenv==20.14.1
virtualenv-clone==0.5.3
virtualenvwrapper==4.8.4
myhost:/tmp$ virtualenv zzz -p python
Running virtualenv with interpreter /usr/bin/python
New python executable in /tmp/zzz/bin/python
Installing setuptools, pip, wheel...done.
myhost:/tmp$ cd zzz
myhost:/tmp/zzz$ source bin/activate
(zzz) myhost:/tmp/zzz$ python -V
Python 2.7.12
(zzz) myhost:/tmp/zzz$ pip -V
pip 20.3.4 from /tmp/zzz/local/lib/python2.7/site-packages/pip (python 2.7)
(zzz) myhost:/tmp/zzz$ pip freeze
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
(zzz) myhost:/tmp/zzz$
So the questions are
Why do I need to use virtualenv 15.0.1? Why can't I use a newer version of virtualenv?
How come python3 is complaining about the missing dataclasses module but python2 is ok?
Like mentioned in this pypi docs; https://pypi.org/project/dataclasses/ dataclasses only exist in 3.7 and above, which i would recommend to use instead, otherwise, you could also download this package in hopes that it fixes your problem. Are you limited to a python version?
i am trying to install gensim using
sudo -H pip install --upgrade gensim
but it is giving me this error :
File "setup.py", line 301, in <module>
include_package_data=True,
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command /install.py", line 67, in run
self.do_egg_install()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command /install.py", line 98, in do_egg_install
easy_install = self.distribution.get_command_class('easy_install')
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 576, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 47, in <module>
from setuptools.sandbox import run_setup
File "/usr/local/lib/python2.7/dist-packages/setuptools/sandbox.py", line 15, in <module>
import pkg_resources.py31compat
ImportError: No module named py31compat
please help me, in installing gensim. i googled it, but i am not able to find the solution.
It looks like setuptoopls is missing. Try
$sudo pip install setuptools
Notice that setuptools come from /usr/local/lib whereas pkg_resources come from /usr/lib. You must likely have an older pkg_resources through the package system and then a newer setuptools installed by pip.
Delete (or move away) the /usr/local/lib/python2.7/dist-packages/setuptools directory.
I encountered a very similar error upon an Ansible run of a refactored OpenShift playbook. The error was discovered once all of the plays were parsed.
"ERROR! Unexpected Exception, this is probably a bug: cannot import name py31compat"
I am using ...
Ansible 2.5.3
Python2-2.7.15
I ran the following command to list the location of all of the packages and libraries associated with Python 2. I checked available paths to ensure I had one version of Ansible and one copy of each package installed.
$ python -c 'import sys; print sys.path'
'py31compat' is not a separate module one can download. It is included with the Setuptools package. It was determined I had two packages installed of different versions, both out-of-date. I uninstalled both via pip and installed the latest setuptools version available. No luck.
My solution was to uninstall Ansible and reinstall the same version. This resolved the issue.
In my case i have odoo v10 installed and for any weird reason update or installed a library that stuck my server and not longer to start with XOE.
The error was:
cannot import name py31compat
After 1 hour trying many differents things i decide uninstall:
sudo pip uninstall setuptools
Uninstalling setuptools-40.8.0: Would remove:
/usr/local/bin/easy_install
/usr/local/bin/easy_install-2.7
/usr/local/lib/python2.7/dist-packages/easy_install.py
/usr/local/lib/python2.7/dist-packages/pkg_resources/*
/usr/local/lib/python2.7/dist-packages/setuptools-40.8.0.dist-info/**
And my service odoo server starts and works fine again!
I followed this instruction to install mtools: https://github.com/rueckstiess/mtools/blob/develop/INSTALL.md. I tried both by pip and building from source but failed to launch it. I got below error when trying to launch mlaunch. I see this error relates to python and I am not familiar with python. Does anyone have any idea on this error?
$ mlaunch
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/mlaunch", line 9, in <module>
load_entry_point('mtools==1.2.4.dev0', 'console_scripts', 'mlaunch')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2697, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
return self.resolve()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mtools-1.2.4.dev0-py2.7.egg/mtools/mlaunch/mlaunch.py", line 40, in <module>
raise ImportError("Can't import pymongo. See http://api.mongodb.org/python/current/ for instructions on how to install pymongo.")
ImportError: Can't import pymongo. See http://api.mongodb.org/python/current/ for instructions on how to install pymongo.
The error message in the trace states:
ImportError: Can't import pymongo. See http://api.mongodb.org/python/current/ for instructions on how to install pymongo.
This means that you are missing a dependency called pymongo to run mlaunch.
You can install pymongo by running the following command:
python -m pip install pymongo
For more information on how to install pymongosee the official documentation: https://api.mongodb.com/python/current/installation.html
I have installed pip according to instructions on pip website. Downloaded get-pip.py and insatlled it with python get-pip.py. Got a confirmation saying installation is successful. Apparently the moment i type pip i get following error:
[fh-mi-sdb99-ma:~/Downloads] sdb99% pip
/Library/Python/2.5/site-packages/pip-6.1.1-py2.5.egg/pip/__init__.py:211: Warning: 'as' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==6.1.1', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2174, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1907, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.5/site-packages/pip-6.1.1-py2.5.egg/pip/__init__.py", line 211
except PipError as exc:
^
SyntaxError: invalid syntax
i am not sure why is this happening..
Any suggestion that would help me to get pip installed correctly on my mac?
Thanks!
EDIT:
[fh-mi-sdb99-ma:~/Downloads] sdb99% python --version
Python 2.7.9
[fh-mi-sdb99-ma:~/Downloads] sdb99% pip --version
/Library/Python/2.5/site-packages/pip-6.1.1-py2.5.egg/pip/__init__.py:211: Warning: 'as' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==6.1.1', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2174, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1907, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.5/site-packages/pip-6.1.1-py2.5.egg/pip/__init__.py", line 211
except PipError as exc:
^
SyntaxError: invalid syntax
Second EDIT:
I have installed python 3.5 pkg but still when i type python on terminal, python 2.7 is initiated..
Your stack trace indicates that you are actually running python2.5
Verification
To verify your python version run python --version.
I would also verify your pip version by running pip --version.
Using the correct python
If you already installed python2.7, you can often specify it specifically, for example: python2.7 my_module.py. Try typing python in your terminal and tap TAB twice. This will list all the python* programs you have in your path. If python2.7 is not listed, you will need to install it.
Using the correct pip
Similar to the above about using the correct python, you should ensure you are using the correct pip.
Try typing pip into your terminal and tap TAB twice. This will list any extra pip versions you have. It is often easier to specify pip2.7.
Download and install Python3.4
If you haven't made a firm decision between python2 and python3, a nice feature of python3 is that python3.4 is bundled with pip, so you don't have to do anything to use it.
Update
Python 2 is end-of-life. Python 3.4+ comes with pip
Original Answer
You are using Python 2.5, outdated version:
/Library/Python/2.5/
Please install at least Python 2.7 first:
https://www.python.org/downloads/
I am running pyjade for Django templates as I find it much easier to write in, but I am trying to convert it to html with the built in converter. When I run pyjade -c django input.jade output.html I get the error pkg_resources.DistributionNotFound: six. However, the package six does in fact exist, and I can import it on python, and when I run pip install six --upgrade it says it is already up-to-date.
Here is the full traceback:
Traceback (most recent call last):
File "/usr/local/bin/pyjade", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2707, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 686, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: six
What would be causing this error?
Re-install via easy_setup (vs pip) solved it for me on OS X Mavericks:
sudo easy_install six
Hope that helps you!
An old setuptools was my culprit.
pip install -U setuptools