Virtualenvwrapper: module 'pkg_resources' has no attribute 'iter_entry_points' - python

Every time I open a new shell, I get this error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/virtualenvwrapper/hook_loader.py", line 223, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/virtualenvwrapper/hook_loader.py", line 132, in main
run_hooks(hook, options, args)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/virtualenvwrapper/hook_loader.py", line 161, in run_hooks
hook_mgr = ExtensionManager(namespace)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/stevedore/extension.py", line 106, in __init__
verify_requirements)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/stevedore/extension.py", line 179, in _load_plugins
for ep in self.list_entry_points():
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/stevedore/extension.py", line 168, in list_entry_points
eps = list(pkg_resources.iter_entry_points(self.namespace))
AttributeError: module 'pkg_resources' has no attribute 'iter_entry_points'
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5 and that PATH is
set properly.
Oddly enough, virtualenvwrapper is still working fine. If I try to activate a virtualenv, it spits out this error again, but the environment does load up. This was after I recently tried to clean up my Python versions on my Mac, but I clearly messed up some path.
Let me know if more info is needed.

Related

Using Python virtualenv-clone returns _Py_HashRandomization_Init: failed to get random numbers to initialize Python

I am running the following line of code and getting the following errors:
If this doesn't work, what is the easiest way to clone the entire venv to another computer?
I want to copy the python interpreter, the venv, and the code all together, without having to reinstall python or anything else on the other PC
virtualenv-clone E:\reader E:\reader2
Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python
Traceback (most recent call last):
File "c:\python\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python\Scripts\virtualenv-clone.exe\__main__.py", line 7, in <module>
File "c:\python\lib\site-packages\clonevirtualenv.py", line 311, in main
clone_virtualenv(old_dir, new_dir)
File "c:\python\lib\site-packages\clonevirtualenv.py", line 77, in clone_virtualenv
version, sys_path = _virtualenv_sys(dst_dir)
File "c:\python\lib\site-packages\clonevirtualenv.py", line 62, in _virtualenv_sys
assert not p.returncode and stdout
AssertionError

An error ocurred while starting the kernel Python in Spyder

I updated Python to version 4.2 with Anaconda Navigator. I am kind of new to programming, but I have an error in the console. It says "An error ocurred while starting the kernel" and than the following:
Traceback (most recent call last):
File "C:\Users\anass\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\anass\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\anass\Anaconda3\lib\site‑packages\spyder_kernels\console\__main__.py", line 23, in
start.main()
File "C:\Users\anass\Anaconda3\lib\site‑packages\spyder_kernels\console\start.py", line 253, in main
import_spydercustomize()
File "C:\Users\anass\Anaconda3\lib\site‑packages\spyder_kernels\console\start.py", line 43, in import_spydercustomize
import spydercustomize
File "C:\Users\anass\Anaconda3\lib\site‑packages\spyder_kernels\customize\spydercustomize.py", line 31, in
from spyder_kernels.customize.spyderpdb import SpyderPdb
File "C:\Users\anass\Anaconda3\lib\site‑packages\spyder_kernels\customize\spyderpdb.py", line 23, in
from IPython.core.inputtransformer2 import TransformerManager
ModuleNotFoundError: No module named 'IPython.core.inputtransformer2'
What should I do to fix this?
When I open Spyder, it says (Python 3.6). Is that maybe part of the problem? Thanks in advance!
(Spyder maintainer here) Please open the Anaconda Prompt and run there
conda update anaconda
conda install ipython=7.6.0
That should fix your problem.

How to create virtualenv python when getting the error mentioned below .?

I am new to Django, I am creating Virtual environment for the new project, I was able to do it for first time, so i have deactivated virtual environment, deleted the whole folder recreate again. Then I am getting errors as mentioned below. How to fix these error?
I have deleted the folder, opened a new command prompt, I have tried to create the virtualenv in another drive(D:) still getting the same errors. I have used the following commands to get it work 'virtualenv .' and 'virtualenv python3 .'
C:\Programming\Django>virtualenv .
C:\users\asus\appdata\local\programs\python\python37\lib\distutils__init__.py:14: UserWarning: The virtualenv distutils package at %s appears to be in the same location as the system distutils?
warnings.warn("The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
Using real prefix 'c:\users\asus\appdata\local\programs\python\python37'
New python executable in D:\Programming\Django\Scripts\python.exe
Command D:\Programming\Django\Scripts\python.exe -m pip config list had error code 1 Traceback (most recent call last):
File "c:\users\asus\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\asus\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\Scripts\virtualenv.exe__main__.py", line 9, in
File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 793, in main
symlink=options.symlink,
File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 1088, in create_environment
install_wheel(to_install, py_executable, search_dirs, download=download)
File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 935, in install_wheel
_install_wheel_with_search_dir(download, project_names, py_executable, search_dirs)
File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 964, in _install_wheel_with_search_dir
config = _pip_config(py_executable, python_path)
File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 1043, in _pip_config
config[key] = ast.literal_eval(value)
File "c:\users\asus\appdata\local\programs\python\python37\lib\ast.py", line 46, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "c:\users\asus\appdata\local\programs\python\python37\lib\ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "", line 1
real_distutils.version
^
IndentationError: unexpected indent
I believe the issue is that your new virtual environment is on D:\ drive, but your general python is on the C:\ drive, and is what you're trying to build from. Although it would be a little odd if this is true (because of how virtual env's are configured), it is possible; it would be like saying start your car without fuel.
The reason I believe this is the problem is because your Traceback error traces back to the C:\ drive, but your virtual environment isn't configured for that, or vice versa. You can see what I mean if we format your logs.
D:\Programming\Django\Scripts\python.exe -m pip config list had error code 1 Traceback (most recent call last):
File "c:\users\asus\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec)
File "c:\users\asus\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\Scripts\virtualenv.exe__main__.py", line 9, in File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 793, in main symlink=options.symlink, File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 1088, in create_environment install_wheel(to_install, py_executable, search_dirs, download=download)
File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 935, in install_wheel _install_wheel_with_search_dir(download, project_names, py_executable, search_dirs) File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 964, in _install_wheel_with_search_dir config = _pip_config(py_executable, python_path)
File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 1043, in _pip_config config[key] = ast.literal_eval(value) File "c:\users\asus\appdata\local\programs\python\python37\lib\ast.py", line 46, in literal_eval node_or_string = parse(node_or_string, mode='eval')
File "c:\users\asus\appdata\local\programs\python\python37\lib\ast.py", line 35, in parse return compile(source, filename, mode, PyCF_ONLY_AST) File "", line 1 real_distutils.version ^ IndentationError: unexpected indent
Because you referenced Django, here is their install guide for windows, just in case. https://docs.djangoproject.com/en/2.2/howto/windows/. If you followed the guide exactly, I would confidently say the issue is not with your environment, and something with your pip install of Django. Maybe try uninstall and reinstall?
Hope this helps! Do let us know what you find.

Numerous remote errors when following TensorFlow Pets on Google Cloud tutorial

Following instructions in the "Distributed Training on the Oxford-IIIT Pets Dataset on Google Cloud" tutorial on the official TensorFlow Models repo, I'm running into some issues. First, this:
Termination reason: Error. Traceback (most recent call last): File
"/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name) File
"/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in
run_globals File
"/root/.local/lib/python2.7/site-packages/object_detection/train.py",
line 51, in from object_detection.builders import
model_builder File
"/root/.local/lib/python2.7/site-packages/object_detection/builders/model_builder.py",
line 29, in from object_detection.meta_architectures import
ssd_meta_arch File
"/root/.local/lib/python2.7/site-packages/object_detection/meta_architectures/ssd_meta_arch.py",
line 32, in from object_detection.utils import
visualization_utils File
"/root/.local/lib/python2.7/site-packages/object_detection/utils/visualization_utils.py",
line 25, in import matplotlib; matplotlib.use('Agg') #
pylint: disable=multiple-statements ImportError: No module named
matplotlib
The takeaway from this was the last part - "No module named matplotlib". Following some advice online, I edited the provided setup.py, to add "matplotlib" as a requirement:
REQUIRED_PACKAGES = ['Pillow>=1.0', 'matplotlib']
Running it again, that solved the issue. Odd - you'd assume with it being a tutorial, it wouldn't have that issue. Next though, it ran into a new issue:
Termination reason: Error. Traceback (most recent call last): File
"/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name) File
"/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in
run_globals File
"/root/.local/lib/python2.7/site-packages/object_detection/train.py",
line 167, in tf.app.run() File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py",
line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough))
File
"/root/.local/lib/python2.7/site-packages/object_detection/train.py",
line 163, in main worker_job_name, is_chief, FLAGS.train_dir) File
"/root/.local/lib/python2.7/site-packages/object_detection/trainer.py",
line 264, in train train_config.prefetch_queue_capacity,
data_augmentation_options) File
"/root/.local/lib/python2.7/site-packages/object_detection/trainer.py",
line 59, in create_input_queue tensor_dict = create_tensor_dict_fn()
File
"/root/.local/lib/python2.7/site-packages/object_detection/train.py",
line 120, in get_next dataset_builder.build(config)).get_next() File
"/root/.local/lib/python2.7/site-packages/object_detection/builders/dataset_builder.py",
line 164, in build functools.partial(tf.data.TFRecordDataset,
buffer_size=8 * 1000 * 1000), AttributeError: 'module' object has no
attribute 'data' The replica worker 0 exited with a non-zero status of
1.
With no relevant search results for this issue, it's difficult to know what the problem is, though one answer suggested an out of date version of TensorFlow. The stated TensorFlow version for this project is TensorFlow 1.2. TensorFlow is now on version 1.7, so maybe that's where the issue arrises. The options for runtime version list are 1.2, 1.4, 1.5 and 1.6. Trying it with 1.6, I got a different error:
Termination reason: Error. Traceback (most recent call last): [...]
File
"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim/python/slim/learning.py",
line 746, in train master, start_standard_services=False,
config=session_config) as sess: File
"/usr/lib/python2.7/contextlib.py", line 17, in enter return
self.gen.next() File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/supervisor.py",
line 1000, in managed_session
self.stop(close_summary_writer=close_summary_writer) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/supervisor.py",
line 828, in stop ignore_live_threads=ignore_live_threads) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/coordinator.py",
line 389, in join six.reraise(*self._exc_info_to_raise) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/supervisor.py",
line 989, in managed_session
start_standard_services=start_standard_services) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/supervisor.py",
line 734, in prepare_or_wait_for_session max_wait_secs=max_wait_secs)
File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/session_manager.py",
line 402, in wait_for_session sess) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/session_manager.py",
line 486, in _try_run_local_init_op sess.run(self._local_init_op) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 905, in run run_metadata_ptr) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 1137, in _run feed_dict_tensor, options, run_metadata) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 1355, in _do_run options, run_metadata) File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py",
line 1374, in _do_call raise type(e)(node_def, op, message)
UnavailableError: OS Error The replica worker 1 exited with a non-zero
status of 1.
Again, there doesn't seem to be a solution to this error right now. So I'm stabbing in the dark. I try it again with TensorFlow 1.4. New error:
Termination reason: Error. Traceback (most recent call last): File
"/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name) File
"/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in
run_globals File
"/root/.local/lib/python2.7/site-packages/object_detection/train.py",
line 167, in tf.app.run() File
"/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py",
line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough))
File
"/root/.local/lib/python2.7/site-packages/object_detection/train.py",
line 163, in main worker_job_name, is_chief, FLAGS.train_dir) File
"/root/.local/lib/python2.7/site-packages/object_detection/trainer.py",
line 264, in train train_config.prefetch_queue_capacity,
data_augmentation_options) File
"/root/.local/lib/python2.7/site-packages/object_detection/trainer.py",
line 59, in create_input_queue tensor_dict = create_tensor_dict_fn()
File
"/root/.local/lib/python2.7/site-packages/object_detection/train.py",
line 120, in get_next dataset_builder.build(config)).get_next() File
"/root/.local/lib/python2.7/site-packages/object_detection/builders/dataset_builder.py",
line 165, in build process_fn, config.input_path[:],
input_reader_config) File
"/root/.local/lib/python2.7/site-packages/object_detection/utils/dataset_util.py",
line 133, in read_dataset tf.contrib.data.parallel_interleave(
AttributeError: 'module' object has no attribute 'parallel_interleave'
The replica worker 0 exited with a non-zero status of 1
I'm finding myself deep within a world of errors now, and don't really know what my next steps should be. I'm simply following the steps of the tutorial, executing the lines of code they say to execute, and receiving these remote errors after 5-10 mins of execution.
Any advice on how to overcome these issues would be appreciated.
You have an installation issue. Uninstall everything and confirm uninstalled by starting Python and importing what you uninstalled to ensure you observe ImportError for each uninstalled package.
Then carefully follow the steps on the installation page which indeed indicate separate installation steps for matplotlib and more.
Some of these errors were supposed to be happening until the following commit.
Using the repo now, following the instructions in here works for me. Only looks like you need to use --runtime-version 1.7 flag.
If you keep having issues make sure you are following the installation instructions using sudo.
If not, some people were still saying they needed to add Tensorflow and Jupyter also in the setup.py (that was not my case though)

QGIS python module is interfering with another python module installed at the system level

I am working with QGIS Pisa in Windows environment.I wanted to upgrade the scipy module of Python present inside OSGeo4W. For that I installed pip from the OSGeo4W windows command shell. I closed the command shell after installation and reopened it.
When I give the pip command inside OSFGeo4W windows command shell, it is referring to pip module installed at the system level and hence I am getting an error. I don't know how to correct this thing. Here is my error stack trace:
Traceback (most recent call last):
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name)
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\runpy.py", line 72, in _run_code exec code in run_globals
File "C:\Python27_32Bit\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\__init__.py", line 13, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\utils\__init__.py", line 26, in <module>
from pip._vendor import pkg_resources
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 76, in <module>
__import__('pip._vendor.packaging.specifiers')
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\packaging\specifiers.py", line 275, in <module>
class Specifier(_IndividualSpecifier):
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\packaging\specifiers.py", line 374, in Specifier
re.VERBOSE | re.IGNORECASE,
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\re.py", line 190, in compile return _compile(pattern, flags)
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\re.py", line 242, in _compile raise error, v # invalid expression
sre_constants.error: nothing to repeat
As you can see on the stacktrace, 3rd line from top, the code refers to pip module of python installed at the system level instead of pip module installed inside the QGIS Pisa. How can I correctly run this ?

Categories