Resolution: PIPENV Shell Error: Attributeerror: ' Module ' object has no attribute ' run '

Source: Internet
Author: User
Tags call back stdin virtual environment



Display error when switching to virtual environment using PIPENV Shell: Attributeerror: ' Module ' object has no attribute ' run '





Can see the d:\program\python34\lib\site-packages\pipenv\shells.py file is the 62nd line error, the module does not have the properties of the run, so ran to the 62nd line of the file to see





Check run,ctrl+b found to see the source code, the source is as follows:


 
if sys.version_info >= (3, 6):
        # Nearly same args as Popen.__init__ except for timeout, input, and check
        def run(args: _CMD,
                timeout: Optional[float] = ...,
                input: Optional[_TXT] = ...,
                check: bool = ...,
                bufsize: int = ...,
                executable: _PATH = ...,
                stdin: _FILE = ...,
                stdout: _FILE = ...,
                stderr: _FILE = ...,
                preexec_fn: Callable[[], Any] = ...,
                close_fds: bool = ...,
                shell: bool = ...,
                cwd: Optional[_PATH] = ...,
                env: Optional[_ENV] = ...,
                universal_newlines: bool = ...,
                startupinfo: Any = ...,
                creationflags: int = ...,
                restore_signals: bool = ...,
                start_new_session: bool = ...,
                pass_fds: Any = ...,
                *,
                encoding: Optional[str] = ...,
                errors: Optional[str] = ...) -> CompletedProcess: ...
    else:
        # Nearly same args as Popen.__init__ except for timeout, input, and check
        def run(args: _CMD,
                timeout: Optional[float] = ...,
                input: Optional[_TXT] = ...,
                check: bool = ...,
                bufsize: int = ...,
                executable: _PATH = ...,
                stdin: _FILE = ...,
                stdout: _FILE = ...,
                stderr: _FILE = ...,
                preexec_fn: Callable[[], Any] = ...,
                close_fds: bool = ...,
                shell: bool = ...,
                cwd: Optional[_PATH] = ...,
                env: Optional[_ENV] = ...,
                universal_newlines: bool = ...,
                startupinfo: Any = ...,
                creationflags: int = ...,
                restore_signals: bool = ...,
                start_new_session: bool = ...,
                pass_fds: Any = ...) -> CompletedProcess: ...


but take a look at the first line If sys.version_info >= (3, 6):, let's guess, this 3.6 is the Python version number, if the version is greater than 3.6, use the first run function, or the second run function, the two functions are different-- The first run function has more of the following two lines


         encoding: Optional[str] = ...,
               errors: Optional[str] = ...)


However, since the version greater than 3.6 and less than 3.6 will call the existing run function, then why the error? Let's take a look at the more complete code



Do not know if the version is greater than 3.5, will go to the second if to determine whether it is greater than 3.6, and my current version is 3.4.4, so do not meet the if judgment greater than 3.5, and meet more than 3.3 if judgment, at this time the following method is call (in fact, as long as the version is satisfied <3.5, the call method should all be called)


 
if sys.version_info >= (3, 5): class CompletedProcess: # morally: _CMD args = ... # type: Any returncode = ... # type: int # morally: Optional[_TXT] stdout = ... # type: Any stderr = ... # type: Any def __init__(self, args: _CMD,
                     returncode: int,
                     stdout: Optional[_TXT] = ...,
                     stderr: Optional[_TXT] = ...) -> None: ... def check_returncode(self) -> None: ... if sys.version_info >= (3, 6): # Nearly same args as Popen.__init__ except for timeout, input, and check def run(args: _CMD,
                timeout: Optional[float] = ...,
                input: Optional[_TXT] = ...,
                check: bool = ...,
                bufsize: int = ...,
                executable: _PATH = ...,
                stdin: _FILE = ...,
                stdout: _FILE = ...,
                stderr: _FILE = ...,
                preexec_fn: Callable[[], Any] = ...,
                close_fds: bool = ...,
                shell: bool = ...,
                cwd: Optional[_PATH] = ...,
                env: Optional[_ENV] = ...,
                universal_newlines: bool = ...,
                startupinfo: Any = ...,
                creationflags: int = ...,
                restore_signals: bool = ...,
                start_new_session: bool = ...,
                pass_fds: Any = ..., *,
                encoding: Optional[str] = ...,
                errors: Optional[str] = ...) -> CompletedProcess: ... else: # Nearly same args as Popen.__init__ except for timeout, input, and check def run(args: _CMD,
                timeout: Optional[float] = ...,
                input: Optional[_TXT] = ...,
                check: bool = ...,
                bufsize: int = ...,
                executable: _PATH = ...,
                stdin: _FILE = ...,
                stdout: _FILE = ...,
                stderr: _FILE = ...,
                preexec_fn: Callable[[], Any] = ...,
                close_fds: bool = ...,
                shell: bool = ...,
                cwd: Optional[_PATH] = ...,
                env: Optional[_ENV] = ...,
                universal_newlines: bool = ...,
                startupinfo: Any = ...,
                creationflags: int = ...,
                restore_signals: bool = ...,
                start_new_session: bool = ...,
                pass_fds: Any = ...) -> CompletedProcess: ... # Same args as Popen.__init__ if sys.version_info >= (3, 3): # 3.3 added timeout  def call(args: _CMD, bufsize: int = ...,
             executable: _PATH = ...,
             stdin: _FILE = ...,
             stdout: _FILE = ...,
             stderr: _FILE = ...,
             preexec_fn: Callable[[], Any] = ...,
             close_fds: bool = ...,
             shell: bool = ...,
             cwd: Optional[_PATH] = ...,
             env: Optional[_ENV] = ...,
             universal_newlines: bool = ...,
             startupinfo: Any = ...,
             creationflags: int = ...,
             restore_signals: bool = ...,
             start_new_session: bool = ...,
             pass_fds: Any = ...,
             timeout: float = ...) -> int: ... else: def call(args: _CMD,
             bufsize: int = ...,
             executable: _PATH = ...,
             stdin: _FILE = ...,
             stdout: _FILE = ...,
             stderr: _FILE = ...,
             preexec_fn: Callable[[], Any] = ...,
             close_fds: bool = ...,
             shell: bool = ...,
             cwd: Optional[_PATH] = ...,
             env: Optional[_ENV] = ...,
             universal_newlines: bool = ...,
             startupinfo: Any = ...,
             creationflags: int = ...,
             restore_signals: bool = ...,
             start_new_session: bool = ...,
             pass_fds: Any = ...) -> int: ...


Understand this, will know how to solve, as long as the change the source code to call the run (if you want to use version 3.5 and above, it is recommended to change the call back to run)





Use the pipenv shell again to find that you can switch to a virtual environment













Reference Articles


Https://cuiqingcai.com/5846.html






Resolution: PIPENV Shell Error: Attributeerror: ' Module ' object has no attribute ' run '


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.