I am trying to get a piece of software called Probemon working and have come up with an error when I try to run it.
As I have both python2 and python3 installed (as per default installation) so I am running the command:
root#root:~/probemon/src$ python2 ./probemon.py -h
Traceback (most recent call last):
File "./probemon.py", line 11, in <module>
import netaddr
File "/usr/local/lib/python2.7/dist-packages/netaddr-0.8.0-py2.7.egg/netaddr/__init__.py", line 18, in <module>
from netaddr.core import (AddrConversionError, AddrFormatError,
File "/usr/local/lib/python2.7/dist-packages/netaddr-0.8.0-py2.7.egg/netaddr/core.py", line 11, in <module>
from netaddr.compat import _callable, _iter_dict_keys
File "/usr/local/lib/python2.7/dist-packages/netaddr-0.8.0-py2.7.egg/netaddr/compat.py", line 93, in <module>
import importlib_resources as _importlib_resources
File "/usr/local/lib/python2.7/dist-packages/importlib_resources-3.0.0-py2.7.egg/importlib_resources/__init__.py", line 5, in <module>
from ._common import (
File "/usr/local/lib/python2.7/dist-packages/importlib_resources-3.0.0-py2.7.egg/importlib_resources/_common.py", line 9, in <module>
from ._compat import (
File "/usr/local/lib/python2.7/dist-packages/importlib_resources-3.0.0-py2.7.egg/importlib_resources/_compat.py", line 42, in <module>
from zipp import Path as ZipPath # type: ignore
File "/usr/local/lib/python2.7/dist-packages/zipp-3.1.0-py2.7.egg/zipp.py", line 217
def open(self, mode='r', *args, pwd=None, **kwargs):
^
SyntaxError: invalid syntax
I am not sure what this error is trying to indicate...
Prior to this I have run these commands:
git clone https://github.com/drkjam/netaddr
cd netaddr
sudo python setup.py install
cd
git clone https://github.com/secdev/scapy.git
cd scapy
sudo python setup.py install
to ensure both netaddr and scapy dependencies are installed
To me, the error looks to have a problem with line 11 import netaddr however IF this is the case, I have already installed this, so I am not sure where the problem lies.
I have also tried running sudo python setup.py install for netaddr and scapy as sudo **python2** setup.py install in their respective directories just in case this made any difference which it did not.
Can anyone tell me what what the error is indicating please.
Thanks
Related
We have an internal wiki and I want to use pywikibot to get some data from it. Installed it from pip but when I import it I get:
>>> import pywikibot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/pywikibot/__init__.py",
line 25, in <module>
from pywikibot.bot import (
File "/usr/local/lib/python3.7/site-packages/pywikibot/bot.py", line
105, in <module>
from pywikibot import config2 as config
File "/usr/local/lib/python3.7/site-packages/pywikibot/config2.py",
line 373, in <module>
base_dir = get_base_dir()
File "/usr/local/lib/python3.7/site-packages/pywikibot/config2.py",
line 367, in get_base_dir
raise RuntimeError(exc_text)
RuntimeError: No user-config.py found in directory '/vagrant'.
Looking here https://www.mediawiki.org/wiki/Manual:Pywikibot/Installation#Configure_Pywikibot
I see a reference to pwb.py, but that does not exist in
/usr/local/lib/python3.7/site-packages/pywikibot.
What am I missing here?
Thanks!
Installing pywikibot from pip currently only installs the library part. The pwb.py and related console scripts are not included in the PyPI package. That means that you'll need to create the user-config.py manually or download the scripts in some other way.
I believe most pywikibot users just clone the git repo. The general process would be something like this:
git clone https://github.com/wikimedia/pywikibot.git --depth 1
python3 -m pip install -U setuptools
python3 -m pip install -e pywikibot/
cd pywikibot/
python3 pwb.py generate_family_file.py https://url.to.your/wiki/api.php? mywikiname
python3 pwb.py generate_user_files.py
# follow the prompts
Adding generate_family_file is in active development:
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/634544
The other two script will follow later I guess.
I have been trying to get pip with python3 on WSL ubuntu 16.04 and have had no success. I have been running sudo apt install --reinstall python3-pip, but still have issues getting pip to work properly.
$ pip3
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 14, in
<module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 23, in
<module>
from pip.locations import (
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in
<module>
from distutils import sysconfig
ImportError: No module named 'distutils'
Similar with sudo
$ sudo pip3
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 14, in
<module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 23, in
<module>
from pip.locations import (
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in <module>
from distutils import sysconfig
ImportError: No module named 'distutils'
Also I noticed that I seem to have two versions of python3 installed:
$ ls /usr/lib | grep python
python2.7
python3
python3.5
According to Python 3 documentation, distutils apparently is not deprecated, BUT, my install of 2.7 has disutils, but 3.6 does not.
When I read:
https://docs.python.org/3/installing/
It seemed to say that distutils was being deprecated, but it was not worded clearly if they were talking about distutils or something else.
If anyone knows the definitive answer, please let us know.
So after a lot of pain, I finally gave in. I had made things worse and corrupted my entire python3 installation. I had corrupted too many files trying to fix everything. I ended up uninstalling WSL/ubuntu and reinstalling clean. I made of backup a few things first.
Unfortunately, this seems to be the best option if you have really messed this up, like I did. Being more careful now, python3 is working just fine, with pip. Make sure you follow official docs when you install.
I'm on Lubuntu (a minimal build of Ubuntu). I installed Python 3.6.1 with:
sudo apt-get install python3.6
I want to use Twilio, so I tried this:
pip install twilio
It said pip wasn't recognized, so I ran this, followed by the above again:
sudo apt install python-pip
I fired up Python 3.6 and tried importing it, but that didn't work out:
>>> from twilio.rest import Client
ModuleNotFoundError: No module named 'twilio'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
I'm new to python3 (which I want to use for the secrets module), Ubuntu, and twilio, so I'm not really sure what's going on here. I'd think if it was as simple as a module not being found, the stack trace would be much shorter... I'm not sure if the stack trace is so long because maybe Python 3 produces longer ones than 2 did, or Ubuntu is trying to do something weird because both Python 2 and 3 are installed (and perhaps two versions of 3 at that), or if maybe this is the work of twilio?
Try the following to download pip:
wget https://bootstrap.pypa.io/get-pip.py
Then install pip by running:
sudo python3 get-pip.py
Then you can install twilio with pip
sudo pip3 install twilio
I'm trying to use the virtualenvwrapper to make a python 3 based virtualenv. However,I'm when I pass the optional interpreter argument, I'm seeing this error. I'm running Ubuntu 15.04. I tried reinstalling virtualenv and virtualenvwrapper without success. Thanks for all your help!
$ mkvirtualenv scriptcutter --python=/usr/bin/python3
Running virtualenv with interpreter /usr/bin/python3
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
if not enabled():
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Original exception was:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
I come across same issue, but after I downgrade virtualenv to 12.0.2, this problem disappears.
This is sort of a workaround for now.
Create a virtualenv using pyvenv.
# install pyvenv on Ubuntu
sudo apt-get install python3-venv
To minimize disruption in your normal workflow, pass a destination directory that is the same as the one used by virtualenvwrapper Like so,
pyvenv example ~/.virtualenvs/example
This is automatically working with workon and cdproject commands. I don't use much else that is provided by virtualenvwrapper
Hope this helps.
You can upgrade to the most recent version of virtualenv, with:
sudo pip install --upgrade https://github.com/pypa/virtualenv/archive/master.zip
virtualenv --version
# Returns 15.2.0.dev0 when I ran it
The following command then works:
mkvirtualenv scriptcutter --python=/usr/bin/python3
Apparently, the develop branch was dropped, so the URL with "develop" will no longer work. My answer was based off of #pjotr_dolphin's comment, with the URL updated.
I'm trying to setup pymysql for python 3.3 on windows 64 bit.
I managed to install easy_install using https://pypi.python.org/pypi/distribute#downloads I did a python distribute_setup.py then easy_install started working.
Now whenever I try to do easy_install pymysql I get
Downloading/unpacking pymysql
Downloading PyMySQL-0.5.tar.gz
Running setup.py egg_info for package pymysql
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\cc\appdata\local\temp\pip-build-Cc\pymysql\setup.py", line 7, in <module>
version_tuple = __import__('pymysql').VERSION
File ".\pymysql\__init__.py", line 28, in <module>
from constants import FIELD_TYPE
ImportError: cannot import name FIELD_TYPE
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\cc\appdata\local\temp\pip-build-Cc\pymysql\setup.py", line 7, in <module>
version_tuple = __import__('pymysql').VERSION
File ".\pymysql\__init__.py", line 28, in <module>
from constants import FIELD_TYPE
ImportError: cannot import name FIELD_TYPE
----------------------------------------
Command python setup.py egg_info failed with error code 1 in c:\users\cc\appdata\local\temp\pip-build-Cc\pymysql
Storing complete log in C:\Users\Cc\pip\pip.log
Originally the error was 'could not import name 'constants'' then I ran easy_install constants and now the error is the one above.
EDIT
Upon closer look I saw they say for python 3.3 to do
echo "Building Python 3.0 version in ./py3k..."
rm -fr ./py3k
mkdir py3k
cp -rf pymysql py3k/
cp setup.py py3k/
cp setup.py.py3k.patch py3k/
cp CHANGELOG py3k/
cp README.rst py3k/
cp LICENSE py3k/
cd py3k
2to3 .|patch -p0
patch setup.py setup.py.py3k.patch
cd ..
Any idea how I can do this in Windows the command 2to3 .|patch -p0
I think you're installing the python2 version.
Try this instead:
easy_install pymysql3