3

Take it easy, I'm a n00b. I get this error when I'm trying to initialize an environment to get a project going. I've scoured through many stack overflow and GitHub (Usage/request) before I decided to post here. I updated pipenv and even updated by python up to 3.7 from 3.6. I've been at it for 2 hours but I decided I may need your help.

pipenv run python3
Creating a virtualenv for this project…
Pipfile: /home/user1/Pipfile
Using /usr/bin/python3 (3.6.7) to create virtualenv…
⠙ Creating virtual environment...
✘ Failed creating virtual environment 
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/user1/.local/lib/python3.6/site-packages/pipenv/cli/command.py", line 408, in run
[pipenv.exceptions.VirtualenvCreationException]:       command=command, args=args, three=state.three, python=state.python, pypi_mirror=state.pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/user1/.local/lib/python3.6/site-packages/pipenv/core.py", line 2310, in do_run
[pipenv.exceptions.VirtualenvCreationException]:       three=three, python=python, validate=False, pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/user1/.local/lib/python3.6/site-packages/pipenv/core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/user1/.local/lib/python3.6/site-packages/pipenv/core.py", line 506, in ensure_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/user1/.local/lib/python3.6/site-packages/pipenv/core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]: 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 "/home/user1/.local/lib/python3.6/site-packages/virtualenv.py", line 26, in <module>
    import logging
ImportError: bad magic number in 'logging': b'\x03\xf3\r\n'
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 26, in <module>
    from apt.package import Package
  File "/usr/lib/python3/dist-packages/apt/package.py", line 24, in <module>
    import logging
ImportError: bad magic number in 'logging': b'\x03\xf3\r\n'

Original exception was:
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 "/home/user1/.local/lib/python3.6/site-packages/virtualenv.py", line 26, in <module>
    import logging
ImportError: bad magic number in 'logging': b'\x03\xf3\r\n'

Failed to create virtual environ

ment.

malformedShoe
  • 31
  • 1
  • 2
  • Have you tried cleaning your .pyc files as per https://tutorials.technology/solved_errors/13-ImportError-bad-magic-number-in-x03-xf3.html – DaveStSomeWhere Jan 25 '19 at 17:24
  • No sir, but I will follow your advice. – malformedShoe Jan 25 '19 at 17:27
  • https://stackoverflow.com/search?q=%5Bpython%5D+ImportError%3A+bad+magic+number – phd Jan 25 '19 at 18:32
  • I have the same issue today with a `make init` in a pipenv project, this [https://github.com/pypa/pipenv/issues/3395] may be the issue and solution to downgrade pipenv to 2018.10.13 with virtualenv 16.0.0 – Conor Jan 26 '19 at 14:38

1 Answers1

1

I think the standalone version is broken, its working for me within an existing venv

(test_123) conor@xxxxxxx:~/workspace/django-machina$ make init
pipenv install --three --dev
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing dependencies from Pipfile.lock (02d410)…
Ignoring appnope: markers 'sys_platform == "darwin"' don't match your environment
Looking in indexes: https://pypi.python.org/simple
     ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 75/75 — 00
Conor
  • 426
  • 7
  • 22