Error when creating a new virtual environment python Windows 10 - python

I am trying to create a new virtual environment using python on Windows 10.The command sets up the folders/subfolder but does not include the necessary scripts to activate the environment.(The folder is empty).
Stack Trace:
C:\Users\mcfry\Documents\Development\Django_Dev\django_test>python3 -m virtualenv my_env
Using base prefix 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0'
New python executable in C:\Users\mcfry\Documents\Development\Django_Dev\django_test\my_env\Scripts\python.exe
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\mcfry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\virtualenv.py", line 2632, in <module>
main()
File "C:\Users\mcfry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\virtualenv.py", line 870, in main
symlink=options.symlink,
File "C:\Users\mcfry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\virtualenv.py", line 1156, in create_environment
install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
File "C:\Users\mcfry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\virtualenv.py", line 1526, in install_python
shutil.copyfile(executable, py_executable)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\mcfry\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\python.exe'

The command you are using is invalid.
Use the following command:
python3 -m venv myenv
or, if you are using virtualenv package, use the following:
virtualenv myenv
Find more details here : Python venv Python virtualenv

Related

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

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

Unable to create virtual environment with virtualenv or pipenv

I am trying to create a virtual env for my flask project. However I tried using both pipenv and virtual env, but both method results in an error. I suspect that it is due to the path.
When I input pipenv shell, this is the log
Creating a virtualenv for this project…
Pipfile: C:\Users\Yk\Pipfile
Using C:\Users\Yk\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe (3.7.6) to create virtualenv…
[== ] Creating virtual environment...The path C:\Users\Yk\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe (from --python=C:\Users\Yk\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe) does not exist
Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pipenv\cli\command.py", line 390, in shell
[pipenv.exceptions.VirtualenvCreationException]: pypi_mirror=state.pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pipenv\core.py", line 2156, in do_shell
[pipenv.exceptions.VirtualenvCreationException]: three=three, python=python, validate=False, pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pipenv\core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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 "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pipenv\core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]: extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.
A empty pipfile is created
When I try to use Virtual Env virtualenv env, this is the log:
Using base prefix 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0'
New python executable in C:\Users\Yk\DOCUME~1\Code\WEBDEV~1\Flask\TESTPR~1\env\Scripts\python.exe
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts\virtualenv.exe\__main__.py", line 7, in <module>
File "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\virtualenv.py", line 870, in main
symlink=options.symlink,
File "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\virtualenv.py", line 1162, in create_environment
install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
File "C:\Users\Yk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\virtualenv.py", line 1532, in install_python
shutil.copyfile(executable, py_executable)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 120, in
copyfile
with open(src, 'rb') as fsrc:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\Yk\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\python.exe'
I have tried unistalling and reinstalling both modules.
I am using python 3.7.
How can i solve this error and use Pipenv? Thank you!
First, check your PATH for python execution or try with this command;
pipenv --rm
pipenv install
It might work, from your error code it will not detect python thats the problem
Okay so basically I reinstalled python. I suspected that it had to do with path, but i couldnt debug it after many hours.
Before i uninstalled though, it is important to remember the modules. So I did
pip freeze --local >pipfreeze.txt
After reinstalling,
pip install --upgrade --force-reinstall -r pipfreeze.txt at the same directory

Can't create and active Virtualenv in windows 10 , python 37

I am new in Python and to be coder :) I am trying to create and active virtualenv, searching for days to fix this problem but I couldn't, can you help me pls..
Thank you.
Let me show you my administrator:
Using base prefix 'c:\\users\\büşra\\appdata\\local\\programs\\python\\python37'
New python executable in C:\Users\Büşra\Desktop\Django-Virtualenv\myenv\Scripts\python.exe
Complete output from command C:\Users\Büşra\Deskt...v\Scripts\python.exe -m pip config list:
Could not import runpy module
ModuleNotFoundError: No module named 'runpy'
----------------------------------------
Traceback (most recent call last):
File "c:\users\büşra\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\büşra\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Büşra\AppData\Local\Programs\Python\Python37\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "c:\users\büşra\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 793, in main
symlink=options.symlink,
File "c:\users\büşra\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 1087, in create_environment
install_wheel(to_install, py_executable, search_dirs, download=download)
File "c:\users\büşra\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\büşra\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\büşra\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 1038, in _pip_config
remove_from_env=["PIP_VERBOSE", "PIP_QUIET"],
File "c:\users\büşra\appdata\local\programs\python\python37\lib\site-packages\virtualenv.py", line 886, in call_subprocess
raise OSError("Command {} failed with error code {}".format(cmd_desc, proc.returncode))
OSError: Command C:\Users\Büşra\Deskt...v\Scripts\python.exe -m pip config list failed with error code 1```
On a windows machine you would activate the virtual environment as follows:
cd into the project directory, if your virtual environment is named venv then this
venv\scripts\activate will activate the virtual environment

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