Skip to content

--always copy useless #1192

Closed
Closed

Description

@RingWong

env: Ubuntu16.04, Anaconda3, virtualenv 15.1.0.
Hi, I want to create a virtualenv, which the packages is copy from site-packages in Anaconda3. I run the following code, new_env is the name:

virtualenv --always copy new_env

But after I activate the new_env, it couldn't import any packages that had been installed in Anaconda3. All the error is ModuleNotFoundError

So, how can I implement my requirement in virtualenv? Thanks!

Activity

  1. mwilck commented on Jul 10, 2018

    @mwilck

    I have a very similar issue with --always-copy on openSUSE tumbleweed. In my case, virtualenv doesn't even finish if run with --always-copy:

    virtualenv --always-copy --verbose /tmp/tgc
    Using base prefix '/usr'
    Creating /tmp/tgc/lib/python3.6
    Cannot find file lib (bad symlink)
    Symlinking Python bootstrap modules
      Copying to /tmp/tgc/lib/python3.6/lib-dynload
      Creating parent directories for /tmp/tgc/lib64/python3.6
      Copying to /tmp/tgc/lib64/python3.6/os.py
      Ignoring built-in bootstrap module: posix
      Copying to /tmp/tgc/lib64/python3.6/posixpath.py
      Cannot import bootstrap module: nt
      Copying to /tmp/tgc/lib64/python3.6/ntpath.py
      Copying to /tmp/tgc/lib64/python3.6/genericpath.py
      Copying to /tmp/tgc/lib64/python3.6/fnmatch.py
      Copying to /tmp/tgc/lib64/python3.6/locale.py
      Copying to /tmp/tgc/lib64/python3.6/encodings
      Copying to /tmp/tgc/lib64/python3.6/codecs.py
      Copying to /tmp/tgc/lib64/python3.6/stat.py
      Cannot import bootstrap module: UserDict
      Creating parent directories for /tmp/tgc/lib64/python3.6/lib-dynload
      Copying to /tmp/tgc/lib64/python3.6/lib-dynload/readline.cpython-36m-x86_64-linux-gnu.so
      Cannot import bootstrap module: copy_reg
      Copying to /tmp/tgc/lib64/python3.6/types.py
      Copying to /tmp/tgc/lib64/python3.6/re.py
      Cannot import bootstrap module: sre
      Copying to /tmp/tgc/lib64/python3.6/sre_parse.py
      Copying to /tmp/tgc/lib64/python3.6/sre_constants.py
      Copying to /tmp/tgc/lib64/python3.6/sre_compile.py
      Copying to /tmp/tgc/lib64/python3.6/lib-dynload/zlib.cpython-36m-x86_64-linux-gnu.so
      Cannot import bootstrap module: _abcoll
      Copying to /tmp/tgc/lib64/python3.6/warnings.py
      Copying to /tmp/tgc/lib64/python3.6/linecache.py
      Copying to /tmp/tgc/lib64/python3.6/abc.py
      Copying to /tmp/tgc/lib64/python3.6/io.py
      Copying to /tmp/tgc/lib64/python3.6/_weakrefset.py
      Copying to /tmp/tgc/lib64/python3.6/copyreg.py
      Copying to /tmp/tgc/lib64/python3.6/tempfile.py
      Copying to /tmp/tgc/lib64/python3.6/random.py
      Copying to /tmp/tgc/lib64/python3.6/__future__.py
      Copying to /tmp/tgc/lib64/python3.6/collections
      Copying to /tmp/tgc/lib64/python3.6/keyword.py
      Copying to /tmp/tgc/lib64/python3.6/tarfile.py
      Copying to /tmp/tgc/lib64/python3.6/shutil.py
      Copying to /tmp/tgc/lib64/python3.6/struct.py
      Copying to /tmp/tgc/lib64/python3.6/copy.py
      Copying to /tmp/tgc/lib64/python3.6/tokenize.py
      Copying to /tmp/tgc/lib64/python3.6/token.py
      Copying to /tmp/tgc/lib64/python3.6/functools.py
      Copying to /tmp/tgc/lib64/python3.6/heapq.py
      Copying to /tmp/tgc/lib64/python3.6/bisect.py
      Copying to /tmp/tgc/lib64/python3.6/weakref.py
      Copying to /tmp/tgc/lib64/python3.6/reprlib.py
      Copying to /tmp/tgc/lib64/python3.6/base64.py
      Copying to /tmp/tgc/lib64/python3.6/_dummy_thread.py
      Copying to /tmp/tgc/lib64/python3.6/hashlib.py
      Copying to /tmp/tgc/lib64/python3.6/hmac.py
      Copying to /tmp/tgc/lib64/python3.6/imp.py
      Copying to /tmp/tgc/lib64/python3.6/importlib
      Copying to /tmp/tgc/lib64/python3.6/rlcompleter.py
      Copying to /tmp/tgc/lib64/python3.6/operator.py
      Copying to /tmp/tgc/lib64/python3.6/_collections_abc.py
      Copying to /tmp/tgc/lib64/python3.6/_bootlocale.py
      Copying to /tmp/tgc/lib64/python3.6/enum.py
    Creating /tmp/tgc/lib/python3.6/site-packages
    Writing /tmp/tgc/lib64/python3.6/site.py
    Writing /tmp/tgc/lib64/python3.6/orig-prefix.txt
    Writing /tmp/tgc/lib64/python3.6/no-global-site-packages.txt
    Creating /tmp/tgc/bin
    New python executable in /tmp/tgc/bin/python3
    Changed mode of /tmp/tgc/bin/python3 to 0o755
    Also creating executable in /tmp/tgc/bin/python
    Changed mode of /tmp/tgc/bin/python to 0o755
    Copying to /tmp/tgc/bin/python
    Copying to /tmp/tgc/bin/python3.6
    Testing executable with /tmp/tgc/bin/python3 -c "import sys;out=sys.stdout;getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))"
    Got sys.prefix result: '/tmp/tgc'
    Creating /tmp/tgc/lib64/python3.6/distutils
    Writing /tmp/tgc/lib64/python3.6/distutils/__init__.py
    Writing /tmp/tgc/lib64/python3.6/distutils/distutils.cfg
    Installing setuptools, pip, wheel...
      Traceback (most recent call last):
        File "<stdin>", line 4, in <module>
        File "/tmp/tgc/lib64/python3.6/tempfile.py", line 45, in <module>
          from random import Random as _Random
        File "/tmp/tgc/lib64/python3.6/random.py", line 42, in <module>
          from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
      ModuleNotFoundError: No module named 'math'
      Complete output from command /tmp/tgc/bin/python3 - setuptools pip wheel:
      Traceback (most recent call last):
      File "<stdin>", line 4, in <module>
      File "/tmp/tgc/lib64/python3.6/tempfile.py", line 45, in <module>
        from random import Random as _Random
      File "/tmp/tgc/lib64/python3.6/random.py", line 42, in <module>
        from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
    ModuleNotFoundError: No module named 'math'
    ----------------------------------------
    ...Installing setuptools, pip, wheel...done.
    Traceback (most recent call last):
      File "/usr/bin/virtualenv", line 11, in <module>
        sys.exit(main())
      File "/usr/lib/python3.6/site-packages/virtualenv.py", line 712, in main
        symlink=options.symlink)
      File "/usr/lib/python3.6/site-packages/virtualenv.py", line 947, in create_environment
        download=download,
      File "/usr/lib/python3.6/site-packages/virtualenv.py", line 904, in install_wheel
        call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
      File "/usr/lib/python3.6/site-packages/virtualenv.py", line 796, in call_subprocess
        % (cmd_desc, proc.returncode))
    OSError: Command /tmp/tgc/bin/python3 - setuptools pip wheel failed with error code 1
    

    As you can see, the "math" module is missing. I can fix this by adding it to the REQUIRED_MODULES list, but then it'll fail with another missing module. I experimented with this for 2 hours and gave up eventually. It seems that --always-copy is simply broken. If I omit --always-copy, everything works fine.

    Forgot to say, this happens both with virtualenv 1.5.1 and virtualenv 1.6.0.

  2. AWhetter commented on Jul 13, 2018

    @AWhetter
    Contributor

    I'm not sure about the original problem but the openSUSE problem should be fixed by #1189

  3. mwilck commented on Jul 13, 2018

    @mwilck

    the openSUSE problem should be fixed by #1189

    I'll give it a try, thanks.

  4. mwilck commented on Jul 20, 2018

    @mwilck

    the openSUSE problem should be fixed by #1189

    Yes it is.

  5. gaborbernat commented on Jan 14, 2019

    @gaborbernat
    Contributor

    Closing as per above.

  6. locked and limited conversation to collaborators on Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions