pycharm 自己的模块导入出错,PyCharm模块导入错误

I am new to PyCharm and am having difficulty importing modules that I have written into the Python console. If I try to import a module that is native to Python I can import that module without difficulty but if I try to import a module that I have written I get an ImportError: No module named 'ModuleITriedToImportName'. For instance here is a simple self written module to pickle files called "filepickle":

import pickle

def saveDbase(filename, object):

file = open(filename, 'wb')

#pickle.dump(object, file) # pickle to file

#pickle.dump(object, open(filename, 'wb'))

pickle.dump(object, file)

file.close() # any file-like object will do

def loadDbase(filename):

file = open(filename, 'rb')

object = pickle.load(file) # unpickle from file

file.close() # recreates object in memory

return object

If I try to "import pickle" at the PyCharm Python Console then the import works without any error. If I try to "import filepickle" I receive the error message:

ImportError: No module named 'filepickle'

The module filepickle works just fine if I run filepickle within PyCharm but I am unable to import filepickle in the Python console. If anybody knows how to get PyCharm to allow me to import modules that I have written into the PyCharm Python console I would appreciate the help.

解决方案

I couldn't reproduce your error (PyCharm 5.0.4, OS X 10.10.5, Python 3.4.3/2.7.6).

You could try run this code in a console to find out the current working directory, and if it's not the same as filepickle's one, most likely it is the problem.

import os

os.getcwd()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值