When ever i mistype or do a error into the console the following message come up:
Traceback (most recent call last):
File "/usr/lib/python3.3/site.py", line 629, in <module>
main()
File "/usr/lib/python3.3/site.py", line 614, in main
known_paths = addusersitepackages(known_paths)
File "/usr/lib/python3.3/site.py", line 284, in addusersitepackages
user_site = getusersitepackages()
File "/usr/lib/python3.3/site.py", line 260, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/lib/python3.3/site.py", line 250, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/lib/python3.3/sysconfig.py", line 610, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python3.3/sysconfig.py", line 560, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/usr/lib/python3.3/sysconfig.py", line 432, in _init_posix
from _sysconfigdata import build_time_vars
File "/usr/lib/python3.3/_sysconfigdata.py", line 6, in <module>
from _sysconfigdata_m import *
ImportError: No module named '_sysconfigdata_m'
I have both Python 2.7 and 3.3 install with Anaconda. I wonder if this is normal or it was a conflict between python 2.7 and 3.3
Assuming you are using ubuntu, here is the relevant bug report https://bugs.launchpad.net/ubuntu/+source/python3.3/+bug/1192890
You need to patch your /etc/bash.bashrc. See comment #6 for details
Actually, it's possible you have another python3 in your PATH before /usr/bin (most probably in /usr/local/bin) in your system, one which lacks the ubuntu-provided libraries (used by /usr/bin/python3). That happens with hashbangs using #!env python3 and the PATH environment variable.
If this is the case, then temporarily make unavailable (eg renaming them) all such non-/usr/bin/python3* executables, do your system administration stuff and then make them again available.
Related
I use Ubuntu 18.04. By mistake, I changed argparse.py file in usr/lib/python3.6. I couldn't fix it and I thought to remove it, so I could reinstall. Now I can't reinstall, whenever I try "pip install argparse" I get an error like this:
Defaulting to user installation because normal site-packages is not writeable
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py", line 279, in run
session = self.get_default_session(options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 74, in get_default_session
self._session = self.enter_context(self._build_session(options))
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 91, in _build_session
index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 241, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 129, in user_agent from pip._vendor import distro
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/distro.py", line 37, in <module>
import argparse ModuleNotFoundError: No module named 'argparse'
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module> sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/main.py", line 75, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 105, in main return self._main(args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 224, in _main self.handle_pip_version_check(options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 146, in handle_pip_version_check timeout=min(5, options.timeout)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 91, in _build_session index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 241, in __init__self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 129, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/distro.py", line 37, in <module>
import argparse
ModuleNotFoundError: No module named 'argparse'
Could you please help me to fix this?
argparse is part of the standard library, not a third-party module. The standard library is not managed via pip (that is both its blessing and its bane).
So you have to fix or reinstall python itself.
argparse is (since Python 3.2) part of the standard library. Just get the file from the official github (I'm assuming cpython, adapt the version as necessary by selecting the correct branch, the link is for python 3.8) and put it back where the one you deleted was
I'm trying to open my jupyter notebook with Conda Python3.6. When I try to open it, I'm getting this error
VikMacBook-Pro:~ vik$ /anaconda3/bin/jupyter_mac.command ; exit;
Failed to import the site module
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site.py", line 541, in <module>
main()
File "/anaconda3/lib/python3.6/site.py", line 522, in main
known_paths = addusersitepackages(known_paths)
File "/anaconda3/lib/python3.6/site.py", line 282, in
addusersitepackages
user_site = getusersitepackages()
File "/anaconda3/lib/python3.6/site.py", line 258, in
getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/anaconda3/lib/python3.6/site.py", line 248, in getuserbase
USER_BASE = get_config_var('userbase')
File "/anaconda3/lib/python3.6/sysconfig.py", line 608, in
get_config_var
return get_config_vars().get(name)
File "/anaconda3/lib/python3.6/sysconfig.py", line 587, in
get_config_vars
import _osx_support
File "/anaconda3/lib/python3.6/_osx_support.py", line 4, in <module>
import re
File "/anaconda3/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
And I have attempted to solve by following this endorsed answer, using command
pip uninstall enum34
However, I'm still getting the following error after running this command
Vik-MacBook-Pro:~ vik$ pip uninstall enum34
Skipping enum34 as it is not installed.
I do not have my own code file named enum.py
try using "pip3 uninstall enum34" it worked for me
I'm building Hello World using cython embed. Using docker python-3.5.3 image (Debian Jessie, with libpython3.5-dev additionaly installed)
hello.py:
print('hello world')
building:
cython --embed -o hello.c hello.py
gcc -I /usr/include/python3.5 -o hello hello.c -lpython3.5m
After trying to run i get ImportError:
Failed to import the site module
Traceback (most recent call last):
File "/usr/lib/python3.5/site.py", line 580, in <module>
main()
File "/usr/lib/python3.5/site.py", line 566, in main
known_paths = addusersitepackages(known_paths)
File "/usr/lib/python3.5/site.py", line 287, in addusersitepackages
user_site = getusersitepackages()
File "/usr/lib/python3.5/site.py", line 263, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/lib/python3.5/site.py", line 253, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/lib/python3.5/sysconfig.py", line 595, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python3.5/sysconfig.py", line 538, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/usr/lib/python3.5/sysconfig.py", line 410, in _init_posix
from _sysconfigdata import build_time_vars
File "/usr/lib/python3.5/_sysconfigdata.py", line 6, in <module>
from _sysconfigdata_m import *
ImportError: No module named '_sysconfigdata_m'
I suggest that something is wrong with PATH or PYTHONPATH, but launching binary file with directly set environment fails with same error.
I used
find / -name '_sysconfigdata_m.py'
/usr/lib/python3.5/plat-x86_64-linux-gnu/_sysconfigdata_m.py
And then
cp /usr/lib/python3.5/plat-x86_64-linux-gnu/_sysconfigdata_m.py /usr/lib/python3.5 Everything worked fine.
But I still wonder - why _sysconfigdata_m is not placed in /usr/lib/python3.5 by default.
I'm trying to run a setup.py script (for mnemosyne). The script fails, and I'm pretty sure I know how to fix the problem, if I could only find the file to edit. The problem is that the traceback points to a non-existent file:
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
I believe that should be loader_path. The problem is that MachOGraph.py file doesn't exist -- not anywhere in my current path, or in my anaconda distribution. There is a build/bdist.macosx-10.5-x86_64/ directory, but no egg. There are a few MachOGraph.py files on my system, but none of them have that line. Nothing under this directory contains the string loader.filename.
What's going on? How can I find that file?
For completeness, here is the complete traceback:
Traceback (most recent call last):
File "/Users/mike/.continuum/anaconda/lib/python2.7/site-packages/ipdb/__main__.py", line 157, in main
pdb._runscript(mainpyfile)
File "/Users/mike/.continuum/anaconda/lib/python2.7/pdb.py", line 1233, in _runscript
self.run(statement)
File "/Users/mike/.continuum/anaconda/lib/python2.7/bdb.py", line 400, in run
exec cmd in globals, locals
File "<string>", line 1, in <module>
File "setup.py", line 241, in <module>
app = py2app_app
File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 654, in run
self._run()
File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 860, in _run
self.run_normal()
File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 950, in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 1110, in create_binaries
platfiles = mm.run()
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
This issue is caused by Pillow, you can use pip uninstall Pillow to uninstall it, then this question will disappear.
Python takes the filename as reported in the bytecode when printing a traceback. In this case, the bytecode contains filenames that are generated to produce a Python egg, a format that contains at least the bytecode files. These paths reflect the build directory relative to the package as it was built.
In this case, it is the py2app installer that includes macholib as a installation requirement; setuptools downloads the source code for that library and produces an egg on demand, in the same location as the py2app egg. I'd look in /usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg for a macholib-1.6-py2.7.egg directory.
With macholib1.7, from line 46 of **/MachOGraph.py...:
try:
fn = dyld_find(filename, env=self.env,
executable_path=self.executable_path,
loader=loader.filename)
self.trans_table[(loader.filename, filename)] = fn
except ValueError:
return None
Change line 49 to:
loader_path=loader.filename)
I installed the Winpython distribution on my copy of Windows 7. Launching iPython consoles and other items from the distribution from within the folder it copied to works fine.
I'd like to use the f2py module from numpy to be able to call Fortran subroutines from Python. My understanding is that f2py must be called from the command line, but the system does not seem to find f2py, returning ImportError: no module named site when I call it either with or without flags. This same error is returned when I try to run python itself from the command line.
When I manually navigate to the Winpython directory (e.g. C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5) and call f2py -c --help-fcompiler to see if f2py is found there, I receive the following error
Traceback (most recent call last):
File ".\lib\site.py", line 538, in main
main()
File ".\lib\site.py", line 530, in main
known_paths = addusersitepackages(known_paths)
File ".\lib\site.py", line 266, in addusersitepackages
user_site = getusersitepackages()
File ".\lib\site.py", line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File ".\lib\site.py", line 231, in getuserbase
USER_BASE = get_config_var('userbase')
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sysconfig.py",
line 516, in get_config_var
return get_config_vars().get(name)
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sysconfig.py",
line 449, in get_config_vars
import re
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\re.py", line 1
05, in <module>
import sre_compile
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sre_parse.py"
", line 14, in <module>
import sre_parse
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sre_constants.py",
line 17, in <module>
from sre_constants import *
File "C:\Users\konings\WinPython-32bit-2.7.5.3\pyt
py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Could somebody explain to me what this error means and/or how to use f2py with Winpython? Thanks!
You can set your environment variable PYTHONPATH pointing to the folder where these modules are. This should solve the ImportErrors.