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

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.

Related

Python pytest hangs. For instance, "pytest --version" simply hangs

The following hangs:
PS C:\Users\Fowler> pytest --version
Notes:
I am in Windows 10.
By hang, I mean at least 5 minutes of waiting for the pytest --version to return...
While waiting for pytest, python.exe is using 100% of a logical processor on my computer.
I uninstalled all python installations with windows installer and I reinistalled python 3.8.0 in an attempt to fix.
pytest only fails when I am not using a venv. So, pytest does work using a venv.
However, I can't use a venv with vscode, because debugging with venv gives a strange "Session-1 timed out waiting for debuggee to spawn" <-- you would think the word debuggee would be a nice clue, but not much found with that word on google. I am guessing this is a different problem, but maybe related?
In summary, I can't debug python with a venv, and I can't run pytest unit tests without a venv. Probably, these items are unrelated... But, because of this catch-22, I will be sooo grateful for any hints to fix either problem.
When I hit <ctrl-c> to break out of the pytest "hang", the following is displayed (but changes a little bit at the end each time?:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\Scripts\pytest.exe\__main__.py", line 7, in <module>
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 72, in main
config = _prepareconfig(args, plugins)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 222, in _prepareconfig
return pluginmanager.hook.pytest_cmdline_parse(
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 203, in _multicall
gen.send(outcome)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\helpconfig.py", line 89, in pytest_cmdline_parse
config = outcome.get_result()
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 742, in pytest_cmdline_parse
self.parse(args)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 948, in parse
self._preparse(args, addopts=addopts)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\config\__init__.py", line 896, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\program files\python38\lib\importlib\metadata.py", line 75, in load
module = import_module(match.group('module'))
File "c:\program files\python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\assertion\rewrite.py", line 138, in exec_module
_write_pyc(state, co, source_stat, pyc)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\assertion\rewrite.py", line 274, in _write_pyc
with atomic_write(fspath(pyc), mode="wb", overwrite=True) as fp:
File "c:\program files\python38\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 156, in _open
with get_fileobject(**self._open_kwargs) as f:
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 247, in _mkstemp_inner
file = _os.path.join(dir, pre + name + suf)
KeyboardInterrupt
The next time try to run pytest --version and I hit <ctrl-c> it ends with:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 248, in _mkstemp_inner
_sys.audit("tempfile.mkstemp", file)
KeyboardInterrupt
The next time try to run pytest --version and I hit <ctrl-c> it ends with:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 256, in _mkstemp_inner
if (_os.name == 'nt' and _os.path.isdir(dir) and
File "c:\program files\python38\lib\genericpath.py", line 42, in isdir
st = os.stat(s)
KeyboardInterrupt
The next time try to run pytest --version and I hit <ctrl-c> it ends with:
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
...
...
File "C:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\atomicwrites\__init__.py", line 173, in get_fileobject
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
File "c:\program files\python38\lib\tempfile.py", line 332, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "c:\program files\python38\lib\tempfile.py", line 250, in _mkstemp_inner
fd = _os.open(file, flags, 0o600)
KeyboardInterrupt
I don't know if this output will help, but I thought it might be useful to see all the locations on my machine where python and/or pytest are installed:
PS C:\Users\Fowler> where.exe /r c:\ python
c:\Program Files\Amazon\AWSCLI\runtime\python.exe
c:\Program Files\Amazon\AWSSAMCLI\runtime\python.exe
c:\Program Files\MySQL\MySQL Workbench 8.0 CE\python.exe
c:\Program Files\Python38\python.exe
c:\Program Files\Python38\Lib\venv\scripts\nt\python.exe
c:\Users\Fowler\.vscode\extensions\lextudio.restructuredtext-116.0.0\out\python.js
c:\Users\Fowler\.vscode\extensions\teabyii.ayu-0.18.0\test\Python.py
c:\Users\Fowler\.vscode\extensions\yzane.markdown-pdf-1.4.1\node_modules\highlight.js\lib\languages\python.js
c:\Users\Fowler\AppData\Local\GitHubDesktop\app-2.2.2\resources\app\highlighter\mode\python.js
c:\Users\Fowler\AppData\Local\GitHubDesktop\app-2.2.3\resources\app\highlighter\mode\python.js
c:\Users\Fowler\AppData\Local\Google\Chrome\User Data\Default\Extensions\ngkhgikojglcgnckopipfdajaifmmnnc\4.1.34_0\python.js
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\etc\apparmor.d\abstractions\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\bash-completion\completions\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\bash-completion\helpers\python
c:\Users\Fowler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\sosreport\sos\plugins\python.py
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\aniso8601\builders\python.py
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\_pytest\python.py
c:\Users\Fowler\Documents\vscodeProjects\playarea\.venv\Scripts\python.exe
c:\Windows\Installer\$PatchCache$\Managed\8B9C64EBE8DD53846B6846E46A14F5EE\3.7.2150\python.exe
c:\Windows\Installer\$PatchCache$\Managed\9CB0624238F6F8F469EAD6566412DD7F\3.7.2150\python.exe
PS C:\Users\Fowler> where.exe /r c:\ pytest
c:\Users\Fowler\AppData\Roaming\Python\Python38\Scripts\pytest.exe
c:\Users\Fowler\AppData\Roaming\Python\Python38\site-packages\pytest.py
And finally! Whew, in case this sheds any light, here is a picture showing the python process having fun eating up my CPU during pytest.py...
I would be oh, so grateful for any assistance or thoughts!
Fixed.
The answer appears to be
Uninstall python via the windows apps and features
Remove the c:\program files\python38 directory
Remove the ..\AppData\Roaming\Python directory
Reinstall
Not sure what the "root" problem was, but a total wipe of python fixed it. Note that the python windows installer does not remove enough python stuff.
Thank you #nneonneo for getting me thinking in the right direction.
You can just run pytest from priviledged (admin) cmd for the first time. For me the issue was fixed and pytest runs from ordinary cmd now without hanging.
I have the similar problem
after i install pytest-cov or allure-pytest, pytest will hang
if i uninstall them , everything is back to normal
I have tried to install different pytest version, It didn't help
but, I tried the method you provide(uninstall python, remove the diretories), it works~, great!
but, when I install allure-pytest again, it fails again.
finally, I found that, I can't install package in privilege cmd window
If I install them in privilege cmd windows, it will make pytest hang!
so, if anyone encounter the problem I have, you can try my way.
In my case, the package anyio, a dependency of JupyterLab, was causing this problem. It was installed at the administrator level. I uninstalled it and reinstalled at the user level and pytest started working again.
Using Ubuntu 18.04/20.04 + Python 3.8.2
My tests were hanging in a similar matter after showing results.
Removing pytest-cov didn't help.
What helped was moving from Python 3.8.2 to a newer version (like 3.8.12)
I ran into the same issue. In my case my IDE didn't load the correct conda environment. So make sure you're in the right environment for your application and use conda activate myEnv to change it if necessary.

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

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.

Cant Launch Jupyter Notebook

Im still a newbie in anaconda, python and jupyter notebook.
I am doing my assignment which is exploring anaconda and jupyter.
windows 10, 64bit
python 3.6.4
anaconda 4.4.10
Why I cant launch jupyter notebook? First time i tried it was successful. And i continue with importing the libraries. Then, when the next time i open anaconda prompt and tried jupyter notebook , i got this error:
Traceback (most recent call last):
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\pkg_resources__init__.py", line 2760, in get_entry_map
ep_map = self._ep_map
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\pkg_resources__init__.py", line 2731, in getattr
raise AttributeError(attr)
AttributeError: _ep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\LENOVO\Anaconda3\Scripts\jupyter-notebook-script.py", line 10, in
sys.exit(main())
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\traitlets\config\application.py", line 657, in launch_instance
app.initialize(argv)
File "", line 2, in initialize
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1507, in initialize
self.init_webapp()
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1270, in init_webapp
self.jinja_environment_options
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 156, in init
default_url, settings_overrides, jinja_env_options)
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 268, in init_settings
nbextensions_path=jupyter_app.nbextensions_path,
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 973, in nbextensions_path
from IPython.paths import get_ipython_dir
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\IPython__init__.py", line 55, in
from .terminal.embed import embed
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\IPython\terminal\embed.py", line 16, in
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\IPython\terminal\interactiveshell.py", line 91, in
class TerminalInteractiveShell(InteractiveShell):
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\IPython\terminal\interactiveshell.py", line 134, in TerminalInteractiveShell
highlighting: \n %s""" % ', '.join(get_all_styles())
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\pygments\styles__init__.py", line 79, in get_all_styles
for name, _ in find_plugin_styles():
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\pygments\plugin.py", line 62, in find_plugin_styles
for entrypoint in iter_entry_points(STYLE_ENTRY_POINT):
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\pkg_resources__init__.py", line 737, in iter_entry_points
entries = dist.get_entry_map(group)
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\pkg_resources__init__.py", line 2763, in get_entry_map
self._get_metadata('entry_points.txt'), self
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\pkg_resources__init__.py", line 2496, in parse_map
raise ValueError("Entry points must be listed in groups")
ValueError: Entry points must be listed in groups
Is a big thank you if anyone can help me solve this! :)
Feel free to drop any comment/suggestion. Thank you!!
First of all i recommend to re install anaconda again and to select the check box which says to Set Anaconda path in system so that you can use it from anywhere.
To make sure that we are going in right direction go to the bin/ in the anaconda folder.
once you are in bin you can see that there is a jupyter-notebook.exe thus execute it in the command prompt.
Also you can try using Anaconda Navigator to do the same thing.
You can also try running it as Administrator if there are any permission issues.
There have been changes in jupyter notebooks latest release so you can read the docs for more info

Getting error while trying to run this command " pipenv install requests " in mac OS

I am facing the following error:
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project…
Using /usr/local/opt/python/bin/python3.6 (3.6.4) to create virtualenv…
⠋Traceback (most recent call last):
File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/site-packages/pipenv/pew/__main__.py", line 8, in <module>
import pew
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pew/__init__.py", line 1, in <module>
from . import pew
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pew/pew.py", line 41, in <module>
from pew._utils import (check_call, invoke, expandpath, own, env_bin_dir,
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pew/_utils.py", line 22, in <module>
encoding = locale.getlocale()[1] or 'ascii'
File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 581, in getlocale
return _parse_localename(localename)
File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 490, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
Virtualenv location:
Creating a Pipfile for this project…
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 366, in install
selective_upgrade=selective_upgrade,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1761, in do_install
skip_requirements=skip_requirements,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 636, in ensure_project
ensure_pipfile(validate=validate, skip_requirements=skip_requirements)
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 289, in ensure_pipfile
project.create_pipfile(python=python)
File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 518, in create_pipfile
'python_version': python_version(required_python)[: len('2.7')]
TypeError: 'NoneType' object is not subscriptable
I tried setting the LANG in ~/.profile and ~/.bash_profile. Both didn't work.
What worked for me on Mac OS X Sierra is adding the following into my ~/.bash_profile file:
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
Then I reloaded the bash profile with: source ~/.bash_profile
For those who use zsh shell, you must add those lines to your ~/.zshrc
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
Then I reload the bash profile with: source ~/.zshrc
For those who use zsh you must add those lines to your ~/.zshrc
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"

Python traceback points to non-existent file

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)

Categories