Couldn't create working virtual environment for Python 3.4

大兔子大兔子 提交于 2019-12-05 12:48:19
mu 無

Is that a shared partition that you have mounted? Does the shared partition have a different filesystem then the non-shared one you tried upon? If yes, then IMO, that will definitely cause an error since you are making and compiling binaries for python on one filesystem, and so it will not work on another filesystem.

As mentioned in this answer, adding to your /etc/fstab with an entry with exec flag might make it work for you, i.e., you might need to add another entry for the NTFS disk here to make it automount:

<file system> <mount point>   <type>  <options>       <dump>  <pass>
-> was on /dev/sdaX during installation
UUID=<uid_of_NTFS> /     ntfs    auto,user,exec,nodev,rw,errors=remount-ro 0       1
John Schmitt

I struggled with this as well so I wrote an ugly bash script to help me with this. The only salient difference between what you do and what I do is on line 133:

/path/to/python/bin/python3.4 /path/to/python/bin/pyvenv /path/to/venv

That is, explicitly name the instance of python and the venv tool. Then

/path/to/venv/bin/pip install django # or whatever

Edit

I installed Linux Mint in a VM to try and build a Python 3.4 virtual environment. Based on the error messages I saw and this answer, I learned that I must do the following to get a complete Python 3.4 build:

apt-get install build-essential libssl-dev openssl

Without this, my Python 3.4 build did not contain pip. Note that you probably want to install readline and other development packages.


Unsolicited Advice

  1. Do not do this as root, create a user dedicated to running your venv
  2. Create a script to create your environment
  3. Check that script into your source code repo

I deleted my python binaries and venvs multiple times and then recreated all of with this script to make sure that my script reproduced my environment and then stripped the identifying information and saved that on github to share it. I should really be using a more formal tool for this like docker/puppet/chef.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!