Python build package error- 'virtualenv' has no attribute 'cli_run' - python

Using Azure Databricks to build a python package. Received the following error from command:
python3 -m build
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/databricks/python3/lib/python3.7/site-packages/build/__main__.py", line 214, in <module>
main(sys.argv[1:], 'python -m build')
File "/databricks/python3/lib/python3.7/site-packages/build/__main__.py", line 206, in main
build_package(args.srcdir, outdir, distributions, config_settings, not args.no_isolation, args.skip_dependencies)
File "/databricks/python3/lib/python3.7/site-packages/build/__main__.py", line 94, in build_package
_build_in_isolated_env(builder, outdir, distributions, config_settings)
File "/databricks/python3/lib/python3.7/site-packages/build/__main__.py", line 52, in _build_in_isolated_env
with IsolatedEnvBuilder() as env:
File "/databricks/python3/lib/python3.7/site-packages/build/env.py", line 65, in __enter__
executable, scripts_dir = _create_isolated_env_virtualenv(self._path)
File "/databricks/python3/lib/python3.7/site-packages/build/env.py", line 156, in _create_isolated_env_virtualenv
result = virtualenv.cli_run(cmd, setup_logging=False)
AttributeError: module 'virtualenv' has no attribute 'cli_run'

I was able to solve the same issue (although in an AWS environment) by upgrading pip and virtualenv:
python3 -m pip install --upgrade pip virtualenv

Related

checking the version of chatter using python -m chatterbot --version.This is the error

python -m chatterbot --version
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/opt/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/anaconda3/lib/python3.7/site-packages/chatterbot/main.py", line 20, in
print(get_chatterbot_version())
File "/opt/anaconda3/lib/python3.7/site-packages/chatterbot/main.py", line 15, in get_chatterbot_version
return config['chatterbot']['version']
File "/opt/anaconda3/lib/python3.7/configparser.py", line 958, in getitem
raise KeyError(key)
KeyError: 'chatterbot'
probably this will work for you:
git clone https://github.com/gunthercox/ChatterBot.git
python3 setup.py install
Sources:
https://github.com/gunthercox/ChatterBot/issues/1940
Hope it help, have a nice day,
David.

Error when trying to intialize an enviroment (Pipenv)) [duplicate]

This question already has answers here:
What's the bad magic number error?
(15 answers)
Closed 4 years ago.
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.
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

cannot use pip in python virtualenv

I created a virtualenv named proj_env and activated in the command prompt of Windows as follows:
C:\Users\me\Desktop\loan_predictor\proj_env\Scripts>activate.bat
(proj_env) C:\Users\me\Desktop\loan_predictor\proj_env\Scripts>pip3 install flask
Traceback (most recent call last):
File "D:\Python\Python35\Lib\runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "D:\Python\Python35\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\me\Desktop\loan_predictor\proj_env\Scripts\pip3.exe\__main__.py", line 5, in <module>
ImportError: No module named 'pip._internal'
I am not sure why both pip and pip3 doesn't work, although it worked when I did pip3 install virtualenv.
What am I missing?

Error while creating the virtual environment [duplicate]

When I used the command virtualenv venv to create the Python virtual environment, the following error occurred:
D:\Flask>virtualenv venv
Using base prefix 'd:\\APP\\python'
New python executable in D:\Flask\venv\Scripts\python.exe
Installing setuptools, pip, wheel...
Complete output from command D:\Flask\venv\Scripts\python.exe - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
ImportError: No module named 'pkgutil'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "d:\APP\python\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "d:\APP\python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\APP\python\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "d:\APP\python\lib\site-packages\virtualenv.py", line 713, in main
symlink=options.symlink)
File "d:\APP\python\lib\site-packages\virtualenv.py", line 945, in create_environment
download=download,
File "d:\APP\python\lib\site-packages\virtualenv.py", line 901, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "d:\APP\python\lib\site-packages\virtualenv.py", line 797, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command D:\Flask\venv\Scripts\python.exe - setuptools pip wheel failed with error code 1
I googled it but didn't find a solution. Does anyone know how to deal with it?
use python -m venv path/to/your/venv to create a virtual environment and then activate it with path/to/your/venv/Scripts/activate.bat (deactivate for quitting the venv)
example:
python -m venv test
test\Scripts\activate.bat
(test) deactivate

Error when using the command "virtualenv venv" to create Python virtual environment

When I used the command virtualenv venv to create the Python virtual environment, the following error occurred:
D:\Flask>virtualenv venv
Using base prefix 'd:\\APP\\python'
New python executable in D:\Flask\venv\Scripts\python.exe
Installing setuptools, pip, wheel...
Complete output from command D:\Flask\venv\Scripts\python.exe - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
ImportError: No module named 'pkgutil'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "d:\APP\python\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "d:\APP\python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\APP\python\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "d:\APP\python\lib\site-packages\virtualenv.py", line 713, in main
symlink=options.symlink)
File "d:\APP\python\lib\site-packages\virtualenv.py", line 945, in create_environment
download=download,
File "d:\APP\python\lib\site-packages\virtualenv.py", line 901, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "d:\APP\python\lib\site-packages\virtualenv.py", line 797, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command D:\Flask\venv\Scripts\python.exe - setuptools pip wheel failed with error code 1
I googled it but didn't find a solution. Does anyone know how to deal with it?
use python -m venv path/to/your/venv to create a virtual environment and then activate it with path/to/your/venv/Scripts/activate.bat (deactivate for quitting the venv)
example:
python -m venv test
test\Scripts\activate.bat
(test) deactivate

Categories

Resources