Issue
I generally use python2.7
for projects.
For one project, I need to use python 3.5+
.
I installed python3 on Mac.
Also installed virtualenv
using pip3.
Now when I run the command
virtualenv -p python3 test
I get the following error:
Running virtualenv with interpreter /usr/bin/python3
Already using interpreter /Library/Developer/CommandLineTools/usr/bin/python3
Using base prefix '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7'
New python executable in /Users/sourabh/virtualenvs/test/bin/python3
Also creating executable in /Users/sourabh/virtualenvs/test/bin/python
Traceback (most recent call last):
File "/Library/Python/3.7/site-packages/virtualenv.py", line 2632, in <module>
main()
File "/Library/Python/3.7/site-packages/virtualenv.py", line 870, in main
symlink=options.symlink,
File "/Library/Python/3.7/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 "/Library/Python/3.7/site-packages/virtualenv.py", line 1621, in install_python
shutil.copy(original_python, py_executable)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/shutil.py", line 245, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/shutil.py", line 103, in copyfile
if _samefile(src, dst):
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/shutil.py", line 88, in _samefile
return os.path.samefile(src, dst)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/genericpath.py", line 96, in samefile
s1 = os.stat(f1)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
Solution
For making a virtual environment with Python 3
Use this for making env
python3 -m venv env
To activate env
source env/bin/activate
Answered By - ParthS007 Answer Checked By - Mildred Charles (WPSolving Admin)