[英]Virtualenv myenv doesn't create virtual environment on exFAT hard drive on Ubuntu 18.04
I am learning Django with python 3.6. 我正在用python 3.6学习Django。 I use Ubuntu 18.04.2 LTS which is also new for me.
我使用Ubuntu 18.04.2 LTS,这对我来说也是新的。 My pip version is 9.0.1.
我的点子版本是9.0.1。 My problem is when I try to create virtual environment on my external exFAT had drive with virtualenv myenv command it gives the error that I shared bellow.
我的问题是,当我尝试使用virtualenv myenv命令在外部exFAT上创建虚拟环境时,它给出了我共享的错误。 But I can create virtual environment on the Desktop with the same command.
但是我可以使用相同的命令在桌面上创建虚拟环境。 The problem is very weird for me.
这个问题对我来说很奇怪。 I can't solve the problem.
我无法解决问题。 Can you guys please help me?
你们能帮我吗? Thanks in advance!
提前致谢!
SAMPLE CODE: ERROR 样本代码:错误
c@p:/media/c/2NDTB/testpro$ virtualenv myenv
Using base prefix '/usr'
Traceback (most recent call last):
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 417, in copyfile
os.symlink(os.path.realpath(src), dest)
OSError: [Errno 38] Function not implemented: '/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu' -> '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu'
During handling of the above exception, another exception occurred: 在处理上述异常期间,发生了另一个异常:
Traceback (most recent call last):
File "/home/c/.local/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 831, in main
symlink=options.symlink,
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 1106, in create_environment
install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 1390, in install_python
copy_required_files(stdlib_dir, lib_dir, symlink)
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 1300, in copy_required_files
copyfile(join(src_dir, fn), join(lib_dir, fn), symlink)
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 420, in copyfile
copy_file_or_folder(src, dest, symlink)
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 398, in copy_file_or_folder
shutil.copytree(src, dest, symlink)
File "/usr/lib/python3.6/shutil.py", line 359, in copytree
raise Error(errors)
shutil.Error: [('/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.so', '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.so', "[Errno 38] Function not implemented: '../../x86_64-linux-gnu/libpython3.6m.so.1' -> '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.so'"), ('/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so', '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so', "[Errno 38] Function not implemented: '../../x86_64-linux-gnu/libpython3.6m.so.1' -> '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so'")]
I see two problems in what you are trying to do. 我在尝试执行操作时遇到两个问题。 The first, smaller problem is that FAT doesn't implement symlinks and virtualenvs by default use symlinks to that version of python they have been created with.
第一个较小的问题是FAT不会实现符号链接,而virtualenvs默认情况下会使用符号链接来创建该版本的python。 You can try
virtualenv --always-copy
to avoid symlinks. 您可以尝试
virtualenv --always-copy
以避免符号链接。
But then you get to the second, bigger problem You're trying to create a virtualenv on a removable drive to port it somewhere. 但是,您遇到了第二个更大的问题,您正在尝试在可移动驱动器上创建一个virtualenv,以将其移植到某个地方。 That doesn't work — virtualenvs are not relocatable.
那行不通-虚拟环境不可重定位。 When you need a virtualenv at a different place you have to recreate it.
当您需要在其他位置使用virtualenv时,必须重新创建它。 To copy the list of installed packages from one virtualenv to another run this in the original virtualenv:
要将已安装软件包的列表从一个virtualenv复制到另一个,请在原始virtualenv中运行此命令:
pip freeze >requirements.txt
then move file requirements.txt
to the other place, create a new virtualenv and restore packages: 然后将文件
requirements.txt
移到另一个位置,创建一个新的virtualenv并还原软件包:
virtualenv venv2
source venv2/bin/activate
pip install -r requirements.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.