能否将本地硬盘的.pdf/.csv等文件上传至VirtualBox虚拟机运行的Jupyter?
Absolutely! You can definitely upload local files like PDFs or CSVs to your Jupyter environment running inside a VirtualBox VM—here are two reliable, easy-to-follow methods to make it happen:
This method creates a persistent link between your host machine and VM, so you can access local files anytime without re-uploading.
Set up the shared folder first:
- Shut down your VM if it’s running, then open the VirtualBox settings for that VM.
- Switch to the Shared Folders tab.
- Click the "+" icon (Add Shared Folder) in the top-right corner.
- For the host path, browse to the local folder where your PDFs/CSVs are stored.
- Check the Auto-mount and Make Permanent boxes—this ensures the folder stays accessible every time you boot the VM.
- Save the settings and start your VM back up.
Access the shared folder in Jupyter:
- Launch Jupyter Notebook or Lab in your VM.
- In the Jupyter file browser, navigate to the mounted shared folder. On Linux VMs, this is typically
/media/sf_YourFolderName(replaceYourFolderNamewith the name you gave the shared folder). On Windows VMs, it’ll show up as a mapped drive letter (like Z:). - From here, you can copy, move, or open your local files directly in your Jupyter workspace.
If you just need to upload a few files quickly, Jupyter’s native upload feature works seamlessly even across the VM boundary:
- Launch Jupyter Notebook or Lab in your VM.
- In the Jupyter file browser, look for the Upload button. For Notebook, it’s usually in the top-right corner; for Lab, check the file menu or toolbar.
- Click the button, then select the local PDFs/CSVs from your host machine’s hard drive.
- Wait a few seconds for the upload to finish—you’ll see the files appear in your Jupyter workspace once it’s done.
Pro Tip: If you’re using a Linux-based VM and get permission errors when accessing the shared folder, run this command in the VM’s terminal to add your user to the required group:sudo usermod -aG vboxsf your_username
Log out and back in to apply the change, and you’ll have full access.
内容的提问来源于stack exchange,提问作者J. Serra

